From af715bf3a127e5db535b5eb89aff8bd4563ef340 Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Tue, 22 Aug 2017 16:55:34 -0700 Subject: [PATCH] Update share_fix.sh layout --- share_fix.sh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/share_fix.sh b/share_fix.sh index fd5ca3d..f5c7ca9 100644 --- a/share_fix.sh +++ b/share_fix.sh @@ -1,21 +1,39 @@ #!/bin/bash -( -volume="data" -#volume=$(rn_nml -g volumes | grep resource-id | awk '{print $2}' | sed 's/resource-id="//;s/"$//') +# share fix +# use this script to rebuild default configs for shares if the ._share becomes +# broken for whatever reason. -for i in `find /$volume/ -mindepth 2 -maxdepth 2 -type d | egrep -v "\/$volume\/home|\/$volume\/.apps|\/$volume\/.vault|\/$volume\/.purge|\/$volume\/._share|\/$volume\/.timemachine|\/$volume\/.TemporaryItems|.iscsi" | sed "s/\/$volume\///g;s/\/.*//g" | sort | uniq`; do mkdir -p /$volume/._share/${i}; cd /$volume/._share/${i}; echo "share" > datasettype.conf; echo "0,25000" > recycle.conf; echo "#dashboard:available=0 \"/$volume/$i\" 127.0.0.1(ro,insecure,insecure_locks,root_squash,anongid=99,anonuid=99,no_subtree_check,sync)" > nfs.conf; echo "" > snapdir.conf; echo "0 0 0 * * * 0" > snapshot.conf; cat > afp.conf << EOF +echo "Activating Share rebuilder" + +volume="data" +echo "Querying readynasd for list of volumes..." +x=$(rn_nml -g volumes | grep "resource-id" | sed 's/^.*id="//;s/".*//;') +number=$(echo $x | wc -w) +echo "$number volume(s) found." +for volume in $x +do + for i in `find /$volume/ -mindepth 2 -maxdepth 2 -type d | egrep -v "\/$volume\/home|\/$volume\/.apps|\/$volume\/.vault|\/$volume\/.purge|\/$volume\/._share|\/$volume\/.timemachine|\/$volume\/.TemporaryItems|.iscsi" | sed "s/\/$volume\///g;s/\/.*//g" | sort | uniq` + do + mkdir -p /$volume/._share/${i} + cd /$volume/._share/${i} + echo "share" > datasettype.conf + echo "0,25000" > recycle.conf + echo "#dashboard:available=0 \"/$volume/$i\" 127.0.0.1(ro,insecure,insecure_locks,root_squash,anongid=99,anonuid=99,no_subtree_check,sync)" > nfs.conf + echo "" > snapdir.conf + echo "0 0 0 * * * 0" > snapshot.conf + cat > afp.conf << EOF [$i] available = 1 path = /$volume/$i invalid users = "guest","nobody","@guest","@nogroup" admin group = admin EOF -cat > fs.conf << EOF + cat > fs.conf << EOF compression = 0 bitrotprotection = 0 refquota = 0 EOF -cat > ftp.conf << EOF + cat > ftp.conf << EOF available 0 default_access writeable mask @@ -28,7 +46,7 @@ user_ro group_ro host_ro EOF -cat > samba.conf << EOF + cat > samba.conf << EOF [$i] path = /$volume/$i comment = "$i folder" @@ -40,6 +58,6 @@ cat > samba.conf << EOF writeable = 1 follow symlinks = 1 EOF -chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf; chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf -done -) \ No newline at end of file + chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf; chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf + done +done \ No newline at end of file