Merge pull request #1617 from pi-hole/hotfix/CIDR

Hotfix/cidr (Pi-hole 3.1.1)
This commit is contained in:
Adam Warner 2017-07-18 09:39:20 +01:00 committed by GitHub
commit b0eceddcec
4 changed files with 22 additions and 15 deletions

View file

@ -19,8 +19,12 @@ readonly ADMIN_INTERFACE_DIR="/var/www/html/admin"
readonly PI_HOLE_GIT_URL="https://github.com/pi-hole/pi-hole.git" readonly PI_HOLE_GIT_URL="https://github.com/pi-hole/pi-hole.git"
readonly PI_HOLE_FILES_DIR="/etc/.pihole" readonly PI_HOLE_FILES_DIR="/etc/.pihole"
# shellcheck disable=SC2034
PH_TEST=true 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"
# is_repo() sourced from basic-install.sh # is_repo() sourced from basic-install.sh
# make_repo() sourced from basic-install.sh # make_repo() sourced from basic-install.sh
@ -30,14 +34,14 @@ source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh
GitCheckUpdateAvail() { GitCheckUpdateAvail() {
local directory="${1}" local directory="${1}"
curdir=$PWD curdir=$PWD
cd "${directory}" cd "${directory}" || return
# Fetch latest changes in this repo # Fetch latest changes in this repo
git fetch --quiet origin git fetch --quiet origin
# @ alone is a shortcut for HEAD. Older versions of git # @ alone is a shortcut for HEAD. Older versions of git
# need @{0} # need @{0}
LOCAL="$(git rev-parse @{0})" LOCAL="$(git rev-parse "@{0}")"
# The suffix @{upstream} to a branchname # The suffix @{upstream} to a branchname
# (short form <branchname>@{u}) refers # (short form <branchname>@{u}) refers
@ -46,7 +50,7 @@ GitCheckUpdateAvail() {
# (configured with branch.<name>.remote and # (configured with branch.<name>.remote and
# branch.<name>.merge). A missing branchname # branch.<name>.merge). A missing branchname
# defaults to the current one. # defaults to the current one.
REMOTE="$(git rev-parse @{upstream})" REMOTE="$(git rev-parse "@{upstream}")"
if [[ ${#LOCAL} == 0 ]]; then if [[ ${#LOCAL} == 0 ]]; then
echo "::: Error: Local revision could not be obtained, ask Pi-hole support." echo "::: Error: Local revision could not be obtained, ask Pi-hole support."
@ -62,7 +66,7 @@ GitCheckUpdateAvail() {
fi fi
# Change back to original directory # Change back to original directory
cd "${curdir}" cd "${curdir}" || exit
if [[ "${LOCAL}" != "${REMOTE}" ]]; then if [[ "${LOCAL}" != "${REMOTE}" ]]; then
# Local branch is behind remote branch -> Update # Local branch is behind remote branch -> Update
@ -77,8 +81,10 @@ GitCheckUpdateAvail() {
FTLcheckUpdate() { FTLcheckUpdate() {
local FTLversion=$(/usr/bin/pihole-FTL tag) local FTLversion
local FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n') 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 if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
return 0 return 0
@ -90,6 +96,7 @@ FTLcheckUpdate() {
main() { main() {
local pihole_version_current local pihole_version_current
local web_version_current local web_version_current
#shellcheck disable=1090,2154
source "${setupVars}" source "${setupVars}"
#This is unlikely #This is unlikely

View file

@ -344,8 +344,8 @@ useIPv6dialog() {
# Determine type of found IPv6 addresses # Determine type of found IPv6 addresses
for i in "${IPV6_ADDRESSES[@]}"; do for i in "${IPV6_ADDRESSES[@]}"; do
result=$(testIPv6 "$i") result=$(testIPv6 "$i")
[[ "${result}" == "ULA" ]] && ULA_ADDRESS="$i" [[ "${result}" == "ULA" ]] && ULA_ADDRESS="${i%/*}"
[[ "${result}" == "GUA" ]] && GUA_ADDRESS="$i" [[ "${result}" == "GUA" ]] && GUA_ADDRESS="${i%/*}"
done done
# Determine which address to be used: Prefer ULA over GUA or don't use any if none found # Determine which address to be used: Prefer ULA over GUA or don't use any if none found
@ -1510,7 +1510,6 @@ main() {
else else
echo "::: Update complete!" echo "::: Update complete!"
fi fi
if [[ ${INSTALL_WEB} == true ]]; then if [[ ${INSTALL_WEB} == true ]]; then
if (( ${#pw} > 0 )) ; then if (( ${#pw} > 0 )) ; then
echo ":::" echo ":::"
@ -1524,7 +1523,8 @@ main() {
fi fi
echo ":::" 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 if [[ "${PH_TEST}" != true ]] ; then

View file

@ -46,9 +46,9 @@ else
exit 1 exit 1
fi fi
#Remove the /* from the end of the IPv4addr. #Remove the /* from the end of the IP addresses
IPV4_ADDRESS=${IPV4_ADDRESS%/*} IPV4_ADDRESS=${IPV4_ADDRESS%/*}
IPV6_ADDRESS=${IPV6_ADDRESS} IPV6_ADDRESS=${IPV6_ADDRESS%/*}
# Variables for various stages of downloading and formatting the list # Variables for various stages of downloading and formatting the list
basename=pihole basename=pihole

View file

@ -7,7 +7,7 @@ run_local = testinfra.get_backend(
def test_scripts_pass_shellcheck(): def test_scripts_pass_shellcheck():
''' Make sure shellcheck does not find anything wrong with our shell scripts ''' ''' 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' | while read file; do shellcheck -x \"$file\" -e SC1090,SC1091; done;"
results = run_local(shellcheck) results = run_local(shellcheck)
print results.stdout print results.stdout
assert '' == results.stdout assert '' == results.stdout