mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-28 17:13:17 +00:00
Checks for root/non-root/sudo
Checks if script is running as root, non-root, or sudo. For root, it sets SUDO variable to nothing and the script runs. If it's not root, then it checks to see if sudo is installed. If it is installed, then it sets SUDO variable to 'sudo' and the script runs. If it is not root and sudo is not installed, then the user does not have sufficient privileges to run the installer and it exits.
This commit is contained in:
parent
b5a0ffe8c1
commit
c168bf4f2e
1 changed files with 7 additions and 2 deletions
|
@ -25,8 +25,13 @@ echo " "
|
||||||
read
|
read
|
||||||
|
|
||||||
#Checks if the script is being run as root and sets sudo accordingly
|
#Checks if the script is being run as root and sets sudo accordingly
|
||||||
SUDO=''
|
echo "Checking if running as root..."
|
||||||
if (( $EUID !=0 )); then SUDO='sudo'
|
if (( $EUID==0 )); then SUDO=''
|
||||||
|
echo "WE ARE ROOT!"
|
||||||
|
elif [ $(dpkg-query -s -f='${Status}' sudo 2>/dev/null | grep -c "ok installed") -eq 1 ]; then SUDO='sudo'
|
||||||
|
echo "sudo IS installed... setting SUDO to sudo!"
|
||||||
|
else echo "Sudo NOT found AND not ROOT! Must run script as root!"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
||||||
|
|
Loading…
Reference in a new issue