Merge branch 'shellcheck694' into 'master'

Add shellcheck fixes and enhancements

See merge request readynas-scripts/share_lun_ui_fix.sh!7
This commit is contained in:
Cody Cook 2018-10-08 22:27:39 -07:00
commit 0d56c8ec3c
2 changed files with 7 additions and 6 deletions

View file

@ -1,4 +1,4 @@
shellcheck: shellcheck:
stage: build stage: build
script: script:
- /usr/bin/shellcheck share_lun_ui_fix.sh - /usr/bin/shellcheck -e SC2164,SC2086 share_lun_ui_fix.sh

View file

@ -133,8 +133,8 @@ EOF
} }
backup_configs() { backup_configs() {
cd "/$volume/._share/" cd "/$volume/._share/"
tar -cf "/var/backups/$volume_sharelunconfig.$(date +%s).tar" ./* 2>/dev/null tar -cf "/var/backups/$volume.sharelunconfig.$(date +%s).tar" ./* 2>/dev/null
} }
echo "===============================" echo "==============================="
@ -168,12 +168,13 @@ 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 */ 2>/dev/null) objects=$(cd /"$volume"; ls -dA ./*/ 2>/dev/null)
if [[ $? == 2 ]]; then if [[ $? == 2 ]]; then
echo "No shares or LUNs found." echo "No shares or LUNs found."
else else
objects=$(echo "$objects" |egrep -v "^.apps\/$|^home\/$|^.purge\/$|^._share\/$|^.timemachine\/$|^.vault\/$|^.TemporaryItems\/$" | sed 's/\/$//') objects=$(echo "$objects" |egrep -v "^.apps\/$|^home\/$|^.purge\/$|^._share\/$|^.timemachine\/$|^.vault\/$|^.TemporaryItems\/$" | sed 's/\/$//;s/\.\///')
echo "= Objects found:" $objects echo "= Objects found: $(echo $objects | wc -w)"
echo $objects
backup_configs backup_configs
for item in $objects; do for item in $objects; do
echo "== Reviewing $item" echo "== Reviewing $item"