use proper check for root privileges

The root user is not guaranteed to be named 'root'
This commit is contained in:
a1346054 2021-08-20 13:11:46 +00:00 committed by goonix
parent b04be889f0
commit e2b9b733af
3 changed files with 6 additions and 6 deletions

View File

@ -77,8 +77,8 @@ if test -t 1; then
fi
fi
# Only allow script to run as
if [ "$(whoami)" != "root" ]; then
# Only allow script to run as root
if (( EUID != 0 )); then
echo -e "${RED}This script needs to be run as root. Try again with 'sudo $0'${NC}"
exit 1
fi

View File

@ -53,8 +53,8 @@ if test -t 1; then
fi
fi
# Only allow script to run as
if [ "$(whoami)" != "root" ]; then
# Only allow script to run as root
if (( EUID != 0 )); then
echo -e "${RED}This script needs to be run as root. Try again with 'sudo $0'${NC}"
exit 1
fi

View File

@ -37,8 +37,8 @@ fi
intCheck='^[0-9]+$'
floatCheck='^[0-9]+([.][0-9]+)?$'
# Only allow script to run as
if [ "$(whoami)" != "root" ]; then
# Only allow script to run as root
if (( EUID != 0 )); then
echo -e "${RED}This script needs to be run as root. Try again with 'sudo $0'${NC}"
exit 1
fi