Skip to content

Commit b0ecedd

Browse files
authored
Merge pull request #1617 from pi-hole/hotfix/CIDR
Hotfix/cidr (Pi-hole 3.1.1)
2 parents ecde222 + 83592a5 commit b0ecedd

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

advanced/Scripts/update.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ readonly ADMIN_INTERFACE_DIR="/var/www/html/admin"
1919
readonly PI_HOLE_GIT_URL="https://github.com/pi-hole/pi-hole.git"
2020
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
2121

22+
# shellcheck disable=SC2034
2223
PH_TEST=true
23-
source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh
24+
25+
# Have to ignore the following rule as spaces in paths are not supported by ShellCheck
26+
#shellcheck disable=SC1090
27+
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
2428

2529
# is_repo() sourced from basic-install.sh
2630
# make_repo() sourced from basic-install.sh
@@ -30,14 +34,14 @@ source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh
3034
GitCheckUpdateAvail() {
3135
local directory="${1}"
3236
curdir=$PWD
33-
cd "${directory}"
37+
cd "${directory}" || return
3438

3539
# Fetch latest changes in this repo
3640
git fetch --quiet origin
3741

3842
# @ alone is a shortcut for HEAD. Older versions of git
3943
# need @{0}
40-
LOCAL="$(git rev-parse @{0})"
44+
LOCAL="$(git rev-parse "@{0}")"
4145

4246
# The suffix @{upstream} to a branchname
4347
# (short form <branchname>@{u}) refers
@@ -46,7 +50,7 @@ GitCheckUpdateAvail() {
4650
# (configured with branch.<name>.remote and
4751
# branch.<name>.merge). A missing branchname
4852
# defaults to the current one.
49-
REMOTE="$(git rev-parse @{upstream})"
53+
REMOTE="$(git rev-parse "@{upstream}")"
5054

5155
if [[ ${#LOCAL} == 0 ]]; then
5256
echo "::: Error: Local revision could not be obtained, ask Pi-hole support."
@@ -62,7 +66,7 @@ GitCheckUpdateAvail() {
6266
fi
6367

6468
# Change back to original directory
65-
cd "${curdir}"
69+
cd "${curdir}" || exit
6670

6771
if [[ "${LOCAL}" != "${REMOTE}" ]]; then
6872
# Local branch is behind remote branch -> Update
@@ -77,8 +81,10 @@ GitCheckUpdateAvail() {
7781

7882
FTLcheckUpdate() {
7983

80-
local FTLversion=$(/usr/bin/pihole-FTL tag)
81-
local FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n')
84+
local FTLversion
85+
FTLversion=$(/usr/bin/pihole-FTL tag)
86+
local FTLlatesttag
87+
FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n')
8288

8389
if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
8490
return 0
@@ -90,6 +96,7 @@ FTLcheckUpdate() {
9096
main() {
9197
local pihole_version_current
9298
local web_version_current
99+
#shellcheck disable=1090,2154
93100
source "${setupVars}"
94101

95102
#This is unlikely

automated install/basic-install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ useIPv6dialog() {
344344
# Determine type of found IPv6 addresses
345345
for i in "${IPV6_ADDRESSES[@]}"; do
346346
result=$(testIPv6 "$i")
347-
[[ "${result}" == "ULA" ]] && ULA_ADDRESS="$i"
348-
[[ "${result}" == "GUA" ]] && GUA_ADDRESS="$i"
347+
[[ "${result}" == "ULA" ]] && ULA_ADDRESS="${i%/*}"
348+
[[ "${result}" == "GUA" ]] && GUA_ADDRESS="${i%/*}"
349349
done
350350

351351
# Determine which address to be used: Prefer ULA over GUA or don't use any if none found
@@ -1510,10 +1510,9 @@ main() {
15101510
else
15111511
echo "::: Update complete!"
15121512
fi
1513-
15141513
if [[ ${INSTALL_WEB} == true ]]; then
15151514
if (( ${#pw} > 0 )) ; then
1516-
echo ":::"
1515+
echo ":::"
15171516
echo "::: Note: As security measure a password has been installed for your web interface"
15181517
echo "::: The currently set password is"
15191518
echo "::: ${pw}"
@@ -1524,7 +1523,8 @@ main() {
15241523
fi
15251524

15261525
echo ":::"
1527-
echo "::: The install log is located at: /etc/pihole/install.log"
1526+
echo "::: The install log is located at: /etc/pihole/install.log
1527+
"
15281528
}
15291529

15301530
if [[ "${PH_TEST}" != true ]] ; then

gravity.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ else
4646
exit 1
4747
fi
4848

49-
#Remove the /* from the end of the IPv4addr.
49+
#Remove the /* from the end of the IP addresses
5050
IPV4_ADDRESS=${IPV4_ADDRESS%/*}
51-
IPV6_ADDRESS=${IPV6_ADDRESS}
51+
IPV6_ADDRESS=${IPV6_ADDRESS%/*}
5252

5353
# Variables for various stages of downloading and formatting the list
5454
basename=pihole

test/test_shellcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def test_scripts_pass_shellcheck():
99
''' Make sure shellcheck does not find anything wrong with our shell scripts '''
10-
shellcheck = "find . -type f \( -name 'update.sh' -o -name 'piholeDebug.sh' \) | while read file; do shellcheck \"$file\"; done;"
10+
shellcheck = "find . -type f -name 'update.sh' | while read file; do shellcheck -x \"$file\" -e SC1090,SC1091; done;"
1111
results = run_local(shellcheck)
1212
print results.stdout
1313
assert '' == results.stdout

0 commit comments

Comments
 (0)