From d124c2c12e78426a823a430eaff4fdcd641ac8a7 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 18:57:19 +0100 Subject: [PATCH] Expand to check web admin versions --- pihole | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/pihole b/pihole index f23db60e..e6f6e292 100755 --- a/pihole +++ b/pihole @@ -57,20 +57,51 @@ function updatePiholeFunc { 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/",$//') + webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0) + webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//') + + echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)" + echo "::: Web Admin version is $webVersion (Latest version is $webVersionLatest)" + if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then - echo "::: Pi-hole is already up to date! Version: ${piholeVersion}" - echo ":::" + echo "::: Pi-hole Base files are already up to date! Version: ${piholeVersionLatest}" echo "::: No need to update!" - else - echo "::: An update is available! Current Version: ${piholeVersion}" - echo "::: Latest Version: ${piholeVersionLatest}" echo ":::" - echo "::: Fetching latest changes from Github..." + + if [[ ${webVersion} == ${webVersionLatest} ]] ; then + echo "::: Web Admin files are already up to date!" + echo "::: No need to update!" + echo ":::" + else + echo "::: An Update is available for the Web Admin!" + echo ":::" + echo "::: Fetching latest changes from GitHub..." + cd /var/www/html/admin + ${SUDO} git pull origin master + echo ":::" + echo "::: Pi-hole Web Admin has been updated to ${webVersion}" + echo "::: See https://changes.pi-hole.net for details" + fi + else + echo -n "::: An update is available for " + if [[ ${webVersion} == ${webVersionLatest} ]] ; then + echo " Pi-Hole!" + else + echo " Pi-Hole base files and the Web Admin. Both will be updated!" + fi + + echo "::: Fetching latest changes from GitHub..." cd /etc/.pihole ${SUDO} git pull origin master ${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole + echo ":::" - echo "::: Pi-hole has been updated, see https://changes.pi-hole.net for details" + echo "::: Pi-hole has been updated to version ${piholeVersionLatest}" + if [[ ${webVersion} != ${webVersionLatest} ]] ; then + echo "::: Web Admin has been updated to version ${webVersionLatest}" + fi + echo ":::" + echo "::: See https://changes.pi-hole.net for details" fi exit 1