From d144bdad758d2e406be8727fb4d57401ba65bbec Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Tue, 22 Aug 2017 17:39:26 -0700 Subject: [PATCH] Fix globbing and other legacy problems --- iscsi_fix.sh | 14 +++++++------- share_fix.sh | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/iscsi_fix.sh b/iscsi_fix.sh index a01d6e1..20ec460 100644 --- a/iscsi_fix.sh +++ b/iscsi_fix.sh @@ -5,22 +5,22 @@ echo "Activating iSCSI share rebuilder" echo "Querying readynasd for list of volumes..." x=$(rn_nml -g volumes | grep "resource-id" | sed 's/^.*id="//;s/".*//;') -number=$(echo $x | wc -w) +number=$(echo "$x" | wc -w) echo "$number volume(s) found." for volume in ${x} do echo -n "Investigating volume /$volume..." - for i in `find /"$volume" -maxdepth 2 -type d -name ".iscsi" | sed "s/\/.iscsi//g;s/\/$volume\///g;"` + for i in $(find /"$volume" -maxdepth 2 -type d -name ".iscsi" | sed "s/\/.iscsi//g;s/\/$volume\///g;") do found=1 path="/$volume/._share/${i}" echo "Found /$volume/${i}... recreating configs...". - mkdir -p $path - cat > $path/iscsi.conf << EOF + mkdir -p "$path" + cat > "$path"/iscsi.conf << EOF comment alert_threshold 80 EOF - cat > $path/custom_snapshot_management.conf << EOF + cat > "$path"/custom_snapshot_management.conf << EOF enabled = no retention_rule = lifetime lifetime = 2592000 @@ -28,7 +28,7 @@ number = 30 nonempty_snapshots = yes prev_versions = no EOF - cat > $path/custom_snapshot_schedule.conf << EOF + cat > "$path"/custom_snapshot_schedule.conf << EOF ........................ ........................ ........................ @@ -37,7 +37,7 @@ EOF ........................ ........................ EOF - cat > $path/snapshot.conf << EOF + cat > "$path"/snapshot.conf << EOF 0 0 0 * 0 0 0 EOF echo " Done with /$volume/${i}." diff --git a/share_fix.sh b/share_fix.sh index ecc159d..c6eda7b 100644 --- a/share_fix.sh +++ b/share_fix.sh @@ -6,29 +6,29 @@ echo "Activating Share rebuilder" echo "Querying readynasd for list of volumes..." x=$(rn_nml -g volumes | grep "resource-id" | sed 's/^.*id="//;s/".*//;') -number=$(echo $x | wc -w) +number=$(echo "$x" | wc -w) echo "$number volume(s) found." for volume in $x do echo -n "Investigating volume /$volume..." - for i in `find /$volume/ -mindepth 1 -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` + for i in $(find /"$volume"/ -mindepth 1 -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 found=1 path="/$volume/._share/${i}" echo "Found /$volume/${i}... recreating configs...". mkdir -p "$path" - echo "share" > $path/datasettype.conf - echo "0,0" > $path/recycle.conf - echo "#dashboard:available=0 \"/$volume/$i\" 127.0.0.1(ro,insecure,insecure_locks,no_subtree_check,crossmnt,anongid=99,anonuid=99,root_squash,async)" > $path/nfs.conf - echo "" > $path/snapdir.conf - echo "0 0 0 * * * 0" > $path/snapshot.conf - cat > $path/afp.conf << EOF + echo "share" > "$path"/datasettype.conf + echo "0,0" > "$path"/recycle.conf + echo "#dashboard:available=0 \"/$volume/$i\" 127.0.0.1(ro,insecure,insecure_locks,no_subtree_check,crossmnt,anongid=99,anonuid=99,root_squash,async)" > "$path"/nfs.conf + echo "" > "$path"/snapdir.conf + echo "0 0 0 * * * 0" > "$path"/snapshot.conf + cat > "$path"/afp.conf << EOF [$i] available = 1 path = /$volume/$i admin group = admin EOF - cat > $path/custom_snapshot_management.conf << EOF + cat > "$path"/custom_snapshot_management.conf << EOF enabled = no retention_rule = lifetime lifetime = 2592000 @@ -36,7 +36,7 @@ number = 30 nonempty_snapshots = yes prev_versions = no EOF - cat > $path/custom_snapshot_schedule.conf << EOF + cat > "$path"/custom_snapshot_schedule.conf << EOF ........................ ........................ ........................ @@ -45,12 +45,12 @@ EOF ........................ ........................ EOF - cat > $path/fs.conf << EOF + cat > "$path"/fs.conf << EOF compression = 0 bitrotprotection = 0 refquota = 0 EOF - cat > $path/ftp.conf << EOF + cat > "$path"/ftp.conf << EOF available 0 default_access disabled mask @@ -63,7 +63,7 @@ user_ro group_ro host_ro EOF - cat > $path/samba.conf << EOF + cat > "$path"/samba.conf << EOF [$i] path = /$volume/$i comment = "$i folder" @@ -74,7 +74,7 @@ EOF follow symlinks = 1 EOF echo -n "Fixing permissions on files..." - cd $path + cd "$path" chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf custom_snapshot_management.conf custom_snapshot_schedule.conf echo " done!"