add piler user param and err check

This commit is contained in:
Asif Bacchus 2019-07-25 12:30:11 -06:00
parent c3aa35ab15
commit 649d162d4c
2 changed files with 21 additions and 3 deletions

View File

@ -4,8 +4,8 @@
"fsPath": "$ROOTPATH$/pilerbackup.sh",
"bookmarks": [
-1,
201,
-1,
301,
46,
-1,
-1,
-1,

View File

@ -43,7 +43,11 @@ badParam () {
elif [ "$1" = "svc" ]; then
printf "${err}\nError: '%s %s': Service does not exist!${norm}\n\n" \
"$2" "$3"
exit 1
exit 1
elif [ "$1" = "user" ]; then
printf "${err}\nError: '%s %s': User does not exist!${norm}\n\n" \
"$2" "$3"
exit 1
fi
}
@ -203,6 +207,7 @@ webroot="/usr/share/nginx/html"
exportAll=0
exportStart=$( date -d 'yesterday' +'%Y.%m.%d' )
exportEnd=$( date -d 'yesterday' +'%Y.%m.%d' )
pilerUser='piler'
### process startup parameters
@ -293,6 +298,19 @@ while [ $# -gt 0 ]; do
badParam empty "$@"
fi
;;
--user)
# specify piler user account name
if [ -n "$2" ]; then
if id ${pilerUser} > /dev/null 2>&1; then
pilerUser="$2"
shift
else
badParam user "$@"
fi
else
badParam empty "$@"
fi
;;
*)
printf "${err}\nUnknown option: %s\n" "$1"
printf "${cyan}Use '--help' for valid options.{$norm}\n\n"