From 82496e238abe3ca4ed8b31b03a96630f329e4442 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 19 Sep 2018 16:09:27 -0600 Subject: [PATCH] Changed root check failure to logged exit with code 2 --- backup.log | 2 ++ backup.sh | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backup.log b/backup.log index 117a5ce..7d29f3d 100644 --- a/backup.log +++ b/backup.log @@ -1 +1,3 @@ [2018-09-19 16:00:05]-- Start backup.sh execution --- +[2018-09-19 16:08:48] -- [ERROR] Script exited with code 2 -- +This script MUST be run as ROOT. diff --git a/backup.sh b/backup.sh index 39efb72..def7898 100755 --- a/backup.sh +++ b/backup.sh @@ -56,7 +56,7 @@ errorExplain=() ### Error codes - +errorExplain[2]="This script MUST be run as ROOT." ### Process script parameters @@ -82,10 +82,9 @@ while getopts ':l:' PARAMS; do done -### Verify script running as root, otherwise exit (un-logged) +### Verify script running as root, otherwise exit if [ $(id -u) -ne 0 ]; then - echo -e "${bold}${red}This script must be run as root. Aborted.${normal}" - exit 2 + quit 2 fi