From 0a0f00da3bf3c2ab769fa0273418ccd33d2ec5a1 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 16 Jan 2016 14:10:03 -0600 Subject: [PATCH] fixes #169 exits if sudo is not installed when run as a regular user --- automated install/basic-install.sh | 10 +++++++++- automated install/uninstall.sh | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b0b94e85..82cfbf96 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -17,11 +17,19 @@ # curl -L install.pi-hole.net | bash ######## VARIABLES ######### +# Must be root to install if [[ $EUID -eq 0 ]];then echo "You are root." else echo "sudo will be used for the install." - export SUDO="sudo" + # Check if it is actually installed + # If it isn't, exit because the install cannot complete + if [[ $(dpkg-query -s sudo) ]];then + export SUDO="sudo" + else + echo "Please install sudo or run this as root." + exit 1 + fi fi diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index a518fa0f..59eca67b 100644 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -13,7 +13,14 @@ if [[ $EUID -eq 0 ]];then echo "You are root." else echo "sudo will be used for the install." - export SUDO="sudo" + # Check if it is actually installed + # If it isn't, exit because the unnstall cannot complete + if [[ $(dpkg-query -s sudo) ]];then + export SUDO="sudo" + else + echo "Please install sudo or run this as root." + exit 1 + fi fi