From ae4e41eaaaab5edffdf4975024ff9c7980a273b7 Mon Sep 17 00:00:00 2001 From: Viet Hung Nguyen Date: Fri, 30 Oct 2020 22:53:20 +0700 Subject: [PATCH] Re-run the script as root instead of piping to bash Signed-off-by: Viet Hung Nguyen --- automated install/basic-install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8560deb9..84cece20 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2623,8 +2623,16 @@ main() { # If the sudo command exists, if is_command sudo ; then printf "%b %b Sudo utility check\\n" "${OVER}" "${TICK}" - # Download the install script and run it with admin rights - exec curl -sSL https://raw.githubusercontent.com/pi-hole/pi-hole/master/automated%20install/basic-install.sh | sudo bash "$@" + + # when run via curl piping + if [[ "$0" == "bash" ]]; then + # Download the install script and run it with admin rights + exec curl -sSL https://raw.githubusercontent.com/pi-hole/pi-hole/master/automated%20install/basic-install.sh | sudo bash "$@" + else + # when run via calling local bash script + exec sudo bash "$0" "$@" + fi + exit $? # Otherwise, else