From 5b0e73c9f30e05ee63f30f1ccf5549792b1f0af6 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Thu, 28 Apr 2016 21:32:24 +0100 Subject: [PATCH] Flesh out updateDependencies. Add in root check. --- advanced/Scripts/updatePiholeSecondary.sh | 35 ++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/updatePiholeSecondary.sh b/advanced/Scripts/updatePiholeSecondary.sh index 88870e77..6989fea4 100644 --- a/advanced/Scripts/updatePiholeSecondary.sh +++ b/advanced/Scripts/updatePiholeSecondary.sh @@ -10,11 +10,44 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +# Must be root to use this tool +if [[ ! $EUID -eq 0 ]];then + #echo "::: You are root." +#else + #echo "::: Sudo will be used for this tool." + # Check if it is actually installed + # If it isn't, exit because the pihole cannot be invoked without privileges. + if [[ $(dpkg-query -s sudo) ]];then + export SUDO="sudo" + else + echo "::: Please install sudo or run this as root." + exit 1 + fi +fi + function updateDependencies(){ + #Add any new dependencies to the below array` newDependencies=() echo "::: Installing any new dependencies..." for i in "${newDependencies[@]}"; do echo "checking for $i" + if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! + echo " done!" + else + echo " already installed!" + fi done } -} \ No newline at end of file +} + +#uncomment the below if adding new dependencies (don't forget to update the install script!) +#updateDependencies + + + +#TODO: +# - Distribute files` +# - Run pihole -g +# - add root check, maybe? Do we need to? Probably a good idea.