From a4b899c2566115d3e1faad2158a171c116dfb4f4 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 23 Aug 2022 19:10:12 +0100 Subject: [PATCH] Review suggestions (and shellcheck complaints) Signed-off-by: Adam Warner --- advanced/Scripts/updatecheck.sh | 30 ++++++++---------------------- advanced/Scripts/version.sh | 4 ++-- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/advanced/Scripts/updatecheck.sh b/advanced/Scripts/updatecheck.sh index 35986676..0c9f385e 100755 --- a/advanced/Scripts/updatecheck.sh +++ b/advanced/Scripts/updatecheck.sh @@ -41,33 +41,19 @@ function get_local_version() { # shellcheck disable=SC1091 . /etc/pihole/setupVars.conf -utilsfile="/opt/pihole/utils.sh" -source "${utilsfile}" +# Source the utils file +# shellcheck disable=SC1091 +. /opt/pihole/utils.sh # Remove the below three legacy files if they exist -GITHUB_VERSION_FILE="/etc/pihole/GitHubVersions" -LOCAL_BRANCH_FILE="/etc/pihole/localbranches" -LOCAL_VERSION_FILE="/etc/pihole/localversions" - -if [ -f "${GITHUB_VERSION_FILE}" ]; then - rm "${GITHUB_VERSION_FILE}" -fi - -if [ -f "${LOCAL_BRANCH_FILE}" ]; then - rm "${LOCAL_BRANCH_FILE}" -fi - -if [ -f "${LOCAL_VERSION_FILE}" ]; then - rm "${LOCAL_VERSION_FILE}" -fi +rm -f "/etc/pihole/GitHubVersions" +rm -f "/etc/pihole/localbranches" +rm -f "/etc/pihole/localversions" # Create new versions file if it does not exist VERSION_FILE="/etc/pihole/versions" - -if [ ! -f "${VERSION_FILE}" ]; then - touch "${VERSION_FILE}" - chmod 644 "${VERSION_FILE}" -fi +touch "${VERSION_FILE}" +chmod 644 "${VERSION_FILE}" if [[ "$2" == "remote" ]]; then diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh index 0bda197e..7f44d35e 100755 --- a/advanced/Scripts/version.sh +++ b/advanced/Scripts/version.sh @@ -89,13 +89,13 @@ getRemoteVersion(){ local daemon="${1}" local version local cachedVersions - local arrCache cachedVersions="/etc/pihole/versions" #If the above file exists, then we can read from that. Prevents overuse of GitHub API if [[ -f "$cachedVersions" ]]; then - source "$cachedVersions" + # shellcheck disable=SC1090 + . "$cachedVersions" case $daemon in "pi-hole" ) echo "${GITHUB_CORE_VERSION}";;