user check

This commit is contained in:
qtwrk
2020-01-17 16:01:24 +01:00
parent 1560edd582
commit 2cd715bb71

View File

@@ -1,8 +1,28 @@
#!/bin/bash
#CyberPanel Upgrade script
export LC_CTYPE=en_US.UTF-8
SUDO_TEST=$(set)
SERVER_OS='Undefined'
OUTPUT=$(cat /etc/*release)
check_root() {
echo -e "\nChecking root privileges...\n"
if echo $SUDO_TEST | grep SUDO > /dev/null ; then
echo -e "\nYou are using SUDO , please run as root user...\n"
echo -e "If you don't have direct access to root user, please run \e[31msudo su -\e[39m command and then run upgrade command again."
exit
fi
if [[ $(id -u) != 0 ]] > /dev/null; then
echo -e "\nYou must use root user to upgrade CyberPanel...\n"
exit
else
echo -e "\nYou are runing as root...\n"
fi
}
check_return() {
#check previous command result , 0 = ok , non-0 = something wrong.
if [[ $? -eq "0" ]] ; then
@@ -13,6 +33,8 @@ else
fi
}
check_root
echo -e "\nChecking OS..."
OUTPUT=$(cat /etc/*release)
if echo $OUTPUT | grep -q "CentOS Linux 7" ; then