From 72015b0226e31bae8b349f4896562bb175bbd696 Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 1 Nov 2016 23:00:14 -0500 Subject: [PATCH 1/4] reduce complexity and un needed cat --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b28b3f3e..496816fb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Works on most Debian and CentOS/RHEL based distributions! ```bash wget -O basic-install.sh https://install.pi-hole.net -cat basic-install.sh | bash +bash basic-install.sh ``` If you wish to read over the script before running it, then after the [`wget`](https://linux.die.net/man/1/wget) command, run `nano basic-install.sh` to open the file in a text viewer. From a8fa061f2e89c24d3123687a89951e979030669b Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 1 Nov 2016 23:02:06 -0500 Subject: [PATCH 2/4] quote all the assignments prevent accidental glob splitting --- advanced/Scripts/update.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 71b0a6ad..c28e4249 100644 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -74,14 +74,14 @@ fi echo "::: Checking for updates..." # Checks Pi-hole version > pihole only > current local git repo version : returns string in format vX.X.X -piholeVersion=$(/usr/local/bin/pihole -v -p -c) +piholeVersion="$(/usr/local/bin/pihole -v -p -c)" # Checks Pi-hole version > pihole only > remote upstream repo version : returns string in format vX.X.X -piholeVersionLatest=$(/usr/local/bin/pihole -v -p -l) +piholeVersionLatest="$(/usr/local/bin/pihole -v -p -l)" # Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X -webVersion=$(/usr/local/bin/pihole -v -a -c) +webVersion="$(/usr/local/bin/pihole -v -a -c)" # Checks Pi-hole version > admin only > remote upstream repo version : returns string in format vX.X.X -webVersionLatest=$(/usr/local/bin/pihole -v -a -l) +webVersionLatest="$(/usr/local/bin/pihole -v -a -l)" echo ":::" echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)" @@ -111,7 +111,7 @@ elif [[ "${piholeVersion} == ${piholeVersionLatest}" ]] && [[ "${webVersion}" != echo "::: Pi-hole Web Admin files out of date" getGitFiles "${WEBINTERFACEDIR}" "${WEBINTERFACEGITURL}" echo ":::" - webVersion=$(/usr/local/bin/pihole -v -a -c) + webVersion="$(/usr/local/bin/pihole -v -a -c)" 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 "" @@ -122,7 +122,7 @@ elif [[ "${piholeVersion}" != "${piholeVersionLatest}" ]] && [[ "${webVersion}" /etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1 echo ":::" - piholeVersion=$(/usr/local/bin/pihole -v -p -c) + piholeVersion="$(/usr/local/bin/pihole -v -p -c)" 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 "" @@ -133,9 +133,9 @@ elif [[ "${piholeVersion}" != "${piholeVersionLatest}" ]] && [[ "${webVersion}" /etc/.pihole/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1 # Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X - webVersion=$(/usr/local/bin/pihole -v -a -c) + webVersion="$(/usr/local/bin/pihole -v -a -c)" # Checks Pi-hole version > admin only > current local git repo version : returns string in format vX.X.X - piholeVersion=$(/usr/local/bin/pihole -v -p -c) + piholeVersion="$(/usr/local/bin/pihole -v -p -c)" echo ":::" 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'" From d986746ef9e1fa565f319adef025bfd168a14435 Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 1 Nov 2016 23:02:50 -0500 Subject: [PATCH 3/4] missing quote added --- advanced/Scripts/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index c28e4249..7b08179d 100644 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -107,7 +107,7 @@ if [[ "${piholeVersion}" == "${piholeVersionLatest}" ]] && [[ "${webVersion}" == 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 ":::" From c30478bf4a594084375c9e5bd766b722e2b96852 Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 1 Nov 2016 23:21:50 -0500 Subject: [PATCH 4/4] cleanup and use sentintel in is_repo --- advanced/Scripts/update.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 7b08179d..0e36c2a2 100644 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -33,15 +33,17 @@ getGitFiles() { is_repo() { # Use git to check if directory is currently under VCS - echo -n "::: Checking $1 is a repo..." - cd "${1}" &> /dev/null || return 1 - if [[ $(git status --short) ]]; then - echo " OK!" - return 0 - else - echo " not found!" - return 1 - fi + local directory="${1}" + local gitRepo=0 + echo -n "::: Checking if ${directory} is a repo... " + cd "${directory}" &> /dev/null || return 1 + if [[ $(git status --short > /dev/null) ]]; then + echo "OK" + else + echo "not found!" + gitRepo=1 + fi; + return ${gitRepo} } make_repo() {