diff --git a/gravity.sh b/gravity.sh index 82e87ae5..6b4a4b74 100755 --- a/gravity.sh +++ b/gravity.sh @@ -6,8 +6,13 @@ piholeIP=$(hostname -I) #Checks if the script is being run as root and sets sudo accordingly -SUDO='' -if (( $EUID !=0 )); then SUDO='sudo' +echo "Checking if running as root..." +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 # Ad-list sources--one per line in single quotes