Merge branch '5-when-no-directories-existed-in-the-volume-tar-felt-obligated-to-error-out' into 'master'

Resolve "When no directories existed in the volume, tar felt obligated to error out..."

Closes #5

See merge request readynas-scripts/share_lun_ui_fix.sh!5
This commit is contained in:
Cody Cook 2017-12-07 21:58:39 -08:00
commit 1bdabe1a5a

View file

@ -109,7 +109,7 @@ EOF
backup_configs() { backup_configs() {
cd "/$volume/._share/" cd "/$volume/._share/"
tar -cf "/var/backups/$volume_sharelunconfig.$(date +%s).tar" ./* tar -cf "/var/backups/$volume_sharelunconfig.$(date +%s).tar" ./* 2>/dev/null
} }
echo "===============================" echo "==============================="
@ -140,7 +140,10 @@ else
echo "===============================" echo "==============================="
for volume in $x; do for volume in $x; do
echo "= Investigating volume /$volume..." echo "= Investigating volume /$volume..."
objects=$(cd /"$volume"; ls -dA */ | egrep -v "^.apps\/$|^home\/$|^.purge\/$|^._share\/$|^.timemachine\/$|^.vault\/$|^.TemporaryItems\/$" | sed 's/\/$//') objects=$(cd /"$volume"; ls -dA */ 2>/dev/null | egrep -v "^.apps\/$|^home\/$|^.purge\/$|^._share\/$|^.timemachine\/$|^.vault\/$|^.TemporaryItems\/$" | sed 's/\/$//')
if [[ $? == 2 ]]; then
echo "No shares or LUNs found."
else
echo "= Objects found:" $objects echo "= Objects found:" $objects
backup_configs backup_configs
for item in $objects; do for item in $objects; do
@ -151,6 +154,7 @@ else
share_create share_create
fi fi
done done
fi
echo "= done with /$volume" echo "= done with /$volume"
done done