Integrate DL's update.sh fixes.

`shellcheck -x` for following files.

Do not test for included files SC1091

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
Signed-off-by: Adam Warner <adamw@rner.email>

# Conflicts:
#	advanced/Scripts/update.sh
This commit is contained in:
Dan Schaper 2017-06-25 14:21:41 -07:00 committed by Adam Warner
parent 66f32b7601
commit 05c8687041
No known key found for this signature in database
GPG Key ID: 03843F6C65554B22
2 changed files with 17 additions and 8 deletions

View File

@ -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 <branchname>@{u}) refers
@ -46,7 +52,7 @@ GitCheckUpdateAvail() {
# (configured with branch.<name>.remote and
# branch.<name>.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

View File

@ -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