From 0c9520d7e35f032fa6a0b3a30f9b98061893d85c Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 1 Nov 2016 11:18:41 -0700 Subject: [PATCH] Protect against unexepcted return values (GitHub not responding as we'd expect.) And make sure bash doesn't maul the variables and cause firing of unattended reinstall of application when values returned aren't as expected. --- advanced/Scripts/update.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index afccd10e..cbbf804f 100644 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -108,12 +108,12 @@ echo ":::" -if [[ ${piholeVersion} == ${piholeVersionLatest} ]] && [[ "${webVersion}" == "${webVersionLatest}" ]]; then +if [[ "${piholeVersion}" == "${piholeVersionLatest}" ]] && [[ "${webVersion}" == "${webVersionLatest}" ]]; then echo "::: Everything is up to date!" echo "" exit 0 -elif [[ ${piholeVersion} == ${piholeVersionLatest} ]] && [[ ${webVersion} != ${webVersionLatest} ]]; then +elif [[ "${piholeVersion} == ${piholeVersionLatest}" ]] && [[ "${webVersion}" != "${webVersionLatest}" ]]; then echo "::: Pi-hole Web Admin files out of date" getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} echo ":::" @@ -121,7 +121,7 @@ elif [[ ${piholeVersion} == ${piholeVersionLatest} ]] && [[ ${webVersion} != ${w echo "::: Web Admin version is now at ${webVersion}" echo "::: If you had made any changes in '/var/www/html/admin', they have been stashed using 'git stash'" echo "" -elif [[ ${piholeVersion} != ${piholeVersionLatest} ]] && [[ ${webVersion} == ${webVersionLatest} ]]; then +elif [[ "${piholeVersion}" != "${piholeVersionLatest}" ]] && [[ "${webVersion}" == "${webVersionLatest}" ]]; then echo "::: Pi-hole core files out of date" getGitFiles ${piholeFilesDir} ${piholeGitUrl} /etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended @@ -130,11 +130,14 @@ elif [[ ${piholeVersion} != ${piholeVersionLatest} ]] && [[ ${webVersion} == ${w echo "::: Pi-hole version is now at ${piholeVersion}" echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'" echo "" -elif [[ ${piholeVersion} != ${piholeVersionLatest} ]] && [[ ${webVersion} != ${webVersionLatest} ]]; then +elif [[ "${piholeVersion}" != "${piholeVersionLatest}" ]] && [[ "${webVersion}" != "${webVersionLatest}" ]]; then echo "::: Updating Everything" getGitFiles ${piholeFilesDir} ${piholeGitUrl} /etc/.pihole/automated\ install/basic-install.sh --unattended + + # Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X webVersion=$(pihole -v -a -c) + # Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X piholeVersion=$(pihole -v -p -c) echo ":::" echo "::: Pi-hole version is now at ${piholeVersion}"