From 48d06eaa58cb4e89dc07078860f00e70e4a8e025 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 3 Oct 2018 15:38:35 -0600 Subject: [PATCH] Separated if statements for prerequisite checks --- backup.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backup.sh b/backup.sh index 2f61efd..87994a1 100755 --- a/backup.sh +++ b/backup.sh @@ -215,12 +215,16 @@ done ### Verify script pre-requisties -# If not running as root, display error on console and exit + +## If not running as root, display error on console and exit if [ $(id -u) -ne 0 ]; then echo -e "\n${err}This script MUST be run as ROOT. Exiting.${normal}" exit 2 +fi + +## Check NextCloud webroot # Ensure NextCloud webroot is provided -elif [ -z "$ncRoot" ]; then +if [ -z "$ncRoot" ]; then echo -e "\n${err}The NextCloud webroot must be specified (-n parameter)" \ "${normal}\n" exit 1 @@ -234,8 +238,11 @@ elif [ -n "$ncRoot" ]; then "(-n parameter) does not exist.${normal}\n" exit 1 fi +fi + +## Check NextCloud webuser account # Ensure NextCloud webuser account is provided -elif [ -z "$webUser" ]; then +if [ -z "$webUser" ]; then echo -e "\n${err}The webuser account running NextCloud must be provided" \ "(-u parameter)${normal}\n" exit 1