From 1a83988e26dc5e931fb3059fc99216fc428409ec Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 1 Oct 2016 16:56:03 +0100 Subject: [PATCH] Add check at the beginning of update script to check for existence of local repos. If not, redirect user to run install command again. --- pihole | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pihole b/pihole index 00e4a7bf..e0d1715a 100755 --- a/pihole +++ b/pihole @@ -49,6 +49,18 @@ function flushFunc { function updatePiholeFunc { + + if [ ! -d "/etc/.pihole" ]; then #This is unlikely + echo "::: Critical Error: Pi-Hole repo missing from system!" + echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" + exit 1; + fi + if [ ! -d "/var/www/html/admin" ]; then #This is unlikely + echo "::: Critical Error: Pi-Hole repo missing from system!" + echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" + exit 1; + fi + echo "::: Checking for updates..." piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0) piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')