From 9464b71a6e37a4067932362fd57f367ef7872d2b Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 26 Jun 2017 09:51:21 -0400 Subject: [PATCH 1/7] Remove /* from IPv6 as well as IPv4 Fixes Discourse issue: https://discourse.pi-hole.net/t/ipv6-aaaa-dns-issue/3830 Signed-off-by: Adam Warner # Conflicts: # gravity.sh --- gravity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 285ce5c3..41e3c68a 100755 --- a/gravity.sh +++ b/gravity.sh @@ -46,9 +46,9 @@ else exit 1 fi -#Remove the /* from the end of the IPv4addr. +#Remove the /* from the end of the IP addresses IPV4_ADDRESS=${IPV4_ADDRESS%/*} -IPV6_ADDRESS=${IPV6_ADDRESS} +IPV6_ADDRESS=${IPV6_ADDRESS%/*} # Variables for various stages of downloading and formatting the list basename=pihole From edb594461d3ac683934eb9b256d93946f92823ad Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 28 Jun 2017 22:54:02 +0100 Subject: [PATCH 2/7] Remove CIDR from IPv6 address when detecting it in the install script Signed-off-by: Adam Warner # Conflicts: # automated install/basic-install.sh --- automated install/basic-install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 053e04ba..2cf2c61d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -344,8 +344,8 @@ useIPv6dialog() { # Determine type of found IPv6 addresses for i in "${IPV6_ADDRESSES[@]}"; do result=$(testIPv6 "$i") - [[ "${result}" == "ULA" ]] && ULA_ADDRESS="$i" - [[ "${result}" == "GUA" ]] && GUA_ADDRESS="$i" + [[ "${result}" == "ULA" ]] && ULA_ADDRESS="${i%/*}" + [[ "${result}" == "GUA" ]] && GUA_ADDRESS="${i%/*}" done # Determine which address to be used: Prefer ULA over GUA or don't use any if none found @@ -1510,10 +1510,9 @@ main() { else echo "::: Update complete!" fi - if [[ ${INSTALL_WEB} == true ]]; then if (( ${#pw} > 0 )) ; then - echo ":::" + echo ":::" echo "::: Note: As security measure a password has been installed for your web interface" echo "::: The currently set password is" echo "::: ${pw}" @@ -1524,7 +1523,8 @@ main() { fi echo ":::" - echo "::: The install log is located at: /etc/pihole/install.log" + echo "::: The install log is located at: /etc/pihole/install.log + " } if [[ "${PH_TEST}" != true ]] ; then From 9101916719a86ab9478496bf18e4e0baa42ab3ab Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Jun 2017 15:49:16 -0700 Subject: [PATCH 3/7] Test exclusion for sourced files SC1090. Signed-off-by: Dan Schaper --- test/test_shellcheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_shellcheck.py b/test/test_shellcheck.py index fa342027..9c4f141b 100644 --- a/test/test_shellcheck.py +++ b/test/test_shellcheck.py @@ -7,7 +7,7 @@ run_local = testinfra.get_backend( def test_scripts_pass_shellcheck(): ''' Make sure shellcheck does not find anything wrong with our shell scripts ''' - shellcheck = "find . -type f \( -name 'update.sh' -o -name 'piholeDebug.sh' \) | while read file; do shellcheck \"$file\"; done;" + shellcheck = "find . -type f \( -name 'update.sh' -o -name 'piholeDebug.sh' \) | while read file; do shellcheck \"$file\" -e SC1090; done;" results = run_local(shellcheck) print results.stdout assert '' == results.stdout From 66f32b7601d52266e7f244cda3f9334f06d5e6ce Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 25 Jun 2017 12:26:16 -0700 Subject: [PATCH 4/7] Remove testing for `debug` as this is getting a re-write by Jacob. Signed-off-by: Dan Schaper --- test/test_shellcheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_shellcheck.py b/test/test_shellcheck.py index 9c4f141b..1b6b35a7 100644 --- a/test/test_shellcheck.py +++ b/test/test_shellcheck.py @@ -7,7 +7,7 @@ run_local = testinfra.get_backend( def test_scripts_pass_shellcheck(): ''' Make sure shellcheck does not find anything wrong with our shell scripts ''' - shellcheck = "find . -type f \( -name 'update.sh' -o -name 'piholeDebug.sh' \) | while read file; do shellcheck \"$file\" -e SC1090; done;" + shellcheck = "find . -type f -name 'update.sh' | while read file; do shellcheck \"$file\" -e SC1090; done;" results = run_local(shellcheck) print results.stdout assert '' == results.stdout From 05c8687041be34065724fd2e33783a47feae10ff Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 25 Jun 2017 14:21:41 -0700 Subject: [PATCH 5/7] Integrate DL's update.sh fixes. `shellcheck -x` for following files. Do not test for included files SC1091 Signed-off-by: Dan Schaper Signed-off-by: Adam Warner # Conflicts: # advanced/Scripts/update.sh --- advanced/Scripts/update.sh | 23 ++++++++++++++++------- test/test_shellcheck.py | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 6aef183b..e3a7f8fd 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -19,8 +19,14 @@ readonly ADMIN_INTERFACE_DIR="/var/www/html/admin" readonly PI_HOLE_GIT_URL="https://github.com/pi-hole/pi-hole.git" readonly PI_HOLE_FILES_DIR="/etc/.pihole" +# shellcheck disable=SC2034 PH_TEST=true -source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh + +# Have to ignore the following rule as spaces in paths are not supported by ShellCheck +#shellcheck disable=SC1090 +source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" + +source "/opt/pihole/COL_TABLE" # is_repo() sourced from basic-install.sh # make_repo() sourced from basic-install.sh @@ -30,14 +36,14 @@ source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh GitCheckUpdateAvail() { local directory="${1}" curdir=$PWD - cd "${directory}" + cd "${directory}" || return # Fetch latest changes in this repo git fetch --quiet origin # @ alone is a shortcut for HEAD. Older versions of git # need @{0} - LOCAL="$(git rev-parse @{0})" + LOCAL="$("git rev-parse @{0}")" # The suffix @{upstream} to a branchname # (short form @{u}) refers @@ -46,7 +52,7 @@ GitCheckUpdateAvail() { # (configured with branch..remote and # branch..merge). A missing branchname # defaults to the current one. - REMOTE="$(git rev-parse @{upstream})" + REMOTE="$("git rev-parse @{upstream}")" if [[ ${#LOCAL} == 0 ]]; then echo "::: Error: Local revision could not be obtained, ask Pi-hole support." @@ -62,7 +68,7 @@ GitCheckUpdateAvail() { fi # Change back to original directory - cd "${curdir}" + cd "${curdir}" || exit if [[ "${LOCAL}" != "${REMOTE}" ]]; then # Local branch is behind remote branch -> Update @@ -77,8 +83,10 @@ GitCheckUpdateAvail() { FTLcheckUpdate() { - local FTLversion=$(/usr/bin/pihole-FTL tag) - local FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n') + local FTLversion + FTLversion=$(/usr/bin/pihole-FTL tag) + local FTLlatesttag + FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n') if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then return 0 @@ -90,6 +98,7 @@ FTLcheckUpdate() { main() { local pihole_version_current local web_version_current + #shellcheck disable=1090,2154 source "${setupVars}" #This is unlikely diff --git a/test/test_shellcheck.py b/test/test_shellcheck.py index 1b6b35a7..5b1a8961 100644 --- a/test/test_shellcheck.py +++ b/test/test_shellcheck.py @@ -7,7 +7,7 @@ run_local = testinfra.get_backend( def test_scripts_pass_shellcheck(): ''' Make sure shellcheck does not find anything wrong with our shell scripts ''' - shellcheck = "find . -type f -name 'update.sh' | while read file; do shellcheck \"$file\" -e SC1090; done;" + shellcheck = "find . -type f -name 'update.sh' | while read file; do shellcheck -x \"$file\" -e SC1090,SC1091; done;" results = run_local(shellcheck) print results.stdout assert '' == results.stdout From 70fb733fea71858494f441d429513d6a77674b21 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 17 Jul 2017 10:53:49 +0100 Subject: [PATCH 6/7] col_table does not exist yet, will break the install if pushed as hotfix. Not sure why these additional "'s were put in, they break the update command, too. Signed-off-by: Adam Warner --- advanced/Scripts/update.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index e3a7f8fd..2ef136a9 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -26,8 +26,6 @@ PH_TEST=true #shellcheck disable=SC1090 source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" -source "/opt/pihole/COL_TABLE" - # is_repo() sourced from basic-install.sh # make_repo() sourced from basic-install.sh # update_repo() source from basic-install.sh @@ -43,7 +41,7 @@ GitCheckUpdateAvail() { # @ alone is a shortcut for HEAD. Older versions of git # need @{0} - LOCAL="$("git rev-parse @{0}")" + LOCAL="$(git rev-parse @{0})" # The suffix @{upstream} to a branchname # (short form @{u}) refers @@ -52,7 +50,7 @@ GitCheckUpdateAvail() { # (configured with branch..remote and # branch..merge). A missing branchname # defaults to the current one. - REMOTE="$("git rev-parse @{upstream}")" + REMOTE="$(git rev-parse @{upstream})" if [[ ${#LOCAL} == 0 ]]; then echo "::: Error: Local revision could not be obtained, ask Pi-hole support." From 83592a5e70a627ea1ba5ab1fce6c99112e9e8f6b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 17 Jul 2017 11:14:02 +0100 Subject: [PATCH 7/7] Put '"'s in the right place Signed-off-by: Adam Warner --- advanced/Scripts/update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 2ef136a9..4281d69f 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -41,7 +41,7 @@ GitCheckUpdateAvail() { # @ alone is a shortcut for HEAD. Older versions of git # need @{0} - LOCAL="$(git rev-parse @{0})" + LOCAL="$(git rev-parse "@{0}")" # The suffix @{upstream} to a branchname # (short form @{u}) refers @@ -50,7 +50,7 @@ GitCheckUpdateAvail() { # (configured with branch..remote and # branch..merge). A missing branchname # defaults to the current one. - REMOTE="$(git rev-parse @{upstream})" + REMOTE="$(git rev-parse "@{upstream}")" if [[ ${#LOCAL} == 0 ]]; then echo "::: Error: Local revision could not be obtained, ask Pi-hole support."