From a6edbf091d970930024c697509778b37cd547025 Mon Sep 17 00:00:00 2001 From: Josh Kastang Date: Sun, 10 Jan 2016 16:48:48 +0000 Subject: [PATCH] attempt to self-elevate to root user to execute script --- automated install/basic-install.sh | 6 +++--- automated install/uninstall.sh | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d3c1c21b..b432e195 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -17,9 +17,9 @@ # curl -L install.pi-hole.net | bash # Must be root to install -if [[ $EUID -ne 0 ]]; then - echo "ERROR: You must run this script as a root user" - exit 1 +if [[ $EUID -ne 0 ]]; then + sudo bash "$0" "$@" + exit $? fi ######## VARIABLES ######### diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 3cc82c52..71ba978b 100644 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -9,11 +9,12 @@ # (at your option) any later version. # Must be root to uninstall -if [[ $EUID -ne 0 ]]; then - echo "ERROR: You must run this script as a root user" - exit 1 +if [[ $EUID -ne 0 ]]; then + sudo bash "$0" "$@" + exit $? fi + ######### SCRIPT ########### apt-get -y remove --purge dnsutils bc toilet apt-get -y remove --purge dnsmasq