From 91b53f1c3583628e7bcfd6f7332180d35ac66d0e Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sun, 30 Sep 2018 20:24:24 -0600 Subject: [PATCH] Add prerequisite parameter check section --- backup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backup.sh b/backup.sh index c018847..b42ab4e 100755 --- a/backup.sh +++ b/backup.sh @@ -162,7 +162,8 @@ warn503="${cyan}${stamp}-- [INFO] Web users will NOT be informed the server is d ### Process script parameters -# if no parameters provided, then show the help page and exit with error +# if no parameters provided, of if parameters do not start with a '-' then show +# the help page and exit with error if [ -z "$1" ] || [[ ! "$1" =~ ^- ]]; then # show script help page scriptHelp @@ -201,10 +202,15 @@ while getopts ':l:nv5:r:' PARAMS; do done -### Verify script running as root, otherwise display error on console and exit +### Verify script pre-requisties +# If not running as root, display error on console and exit if [ $(id -u) -ne 0 ]; then echo -e "${red}This script MUST be run as ROOT. Exiting.${normal}" exit 2 +elif [ -z "$webroot" ]; then + echo -e "\n${red}The NextCloud webroot must be specified (-r parameter)" \ + "${normal}\n" + exit 1 fi