From 7d78f6314ac875c1560dc3e868cde0a72e8b03a6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 30 Sep 2018 19:41:04 +0100 Subject: [PATCH] Source Setupvars file and only check local/remote Web branch/version if the web interface is installed. Signed-off-by: Adam Warner --- advanced/Scripts/updatecheck.sh | 46 +++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/updatecheck.sh b/advanced/Scripts/updatecheck.sh index 767c5461..b8cd9654 100755 --- a/advanced/Scripts/updatecheck.sh +++ b/advanced/Scripts/updatecheck.sh @@ -37,30 +37,54 @@ function get_local_version() { git describe --long --dirty --tags || return 1 } +# Source the setupvars config file +. /etc/pihole/setupVars.conf + if [[ "$2" == "remote" ]]; then if [[ "$3" == "reboot" ]]; then sleep 30 fi - GITHUB_CORE_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/pi-hole/releases/latest' 2> /dev/null)")" - GITHUB_WEB_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/AdminLTE/releases/latest' 2> /dev/null)")" - GITHUB_FTL_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/FTL/releases/latest' 2> /dev/null)")" + GITHUB_VERSION_FILE="/etc/pihole/GitHubVersions" - echo -n "${GITHUB_CORE_VERSION} ${GITHUB_WEB_VERSION} ${GITHUB_FTL_VERSION}" > "/etc/pihole/GitHubVersions" + GITHUB_CORE_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/pi-hole/releases/latest' 2> /dev/null)")" + echo -n "${GITHUB_CORE_VERSION}" > "${GITHUB_VERSION_FILE}" + + if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then + GITHUB_WEB_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/AdminLTE/releases/latest' 2> /dev/null)")" + echo -n " ${GITHUB_WEB_VERSION}" > "${GITHUB_VERSION_FILE}" + fi + + GITHUB_FTL_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/FTL/releases/latest' 2> /dev/null)")" + echo -n " ${GITHUB_FTL_VERSION}" > "${GITHUB_VERSION_FILE}" else - CORE_BRANCH="$(get_local_branch /etc/.pihole)" - WEB_BRANCH="$(get_local_branch /var/www/html/admin)" - FTL_BRANCH="$(pihole-FTL branch)" + LOCAL_BRANCH_FILE="/etc/pihole/localbranches" - echo -n "${CORE_BRANCH} ${WEB_BRANCH} ${FTL_BRANCH}" > "/etc/pihole/localbranches" + CORE_BRANCH="$(get_local_branch /etc/.pihole)" + echo -n "${CORE_BRANCH}" > "${LOCAL_BRANCH_FILE}" + + if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then + WEB_BRANCH="$(get_local_branch /var/www/html/admin)" + echo -n " ${WEB_BRANCH}" > "${LOCAL_BRANCH_FILE}" + fi + + FTL_BRANCH="$(pihole-FTL branch)" + echo -n " ${FTL_BRANCH}" > "${LOCAL_BRANCH_FILE}" + + LOCAL_VERSION_FILE="/etc/pihole/localversions" CORE_VERSION="$(get_local_version /etc/.pihole)" - WEB_VERSION="$(get_local_version /var/www/html/admin)" - FTL_VERSION="$(pihole-FTL version)" + echo -n "${CORE_VERSION}" > "${LOCAL_VERSION_FILE}" - echo -n "${CORE_VERSION} ${WEB_VERSION} ${FTL_VERSION}" > "/etc/pihole/localversions" + if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then + WEB_VERSION="$(get_local_version /var/www/html/admin)" + echo -n " ${WEB_VERSION}" > "${LOCAL_VERSION_FILE}" + fi + + FTL_VERSION="$(pihole-FTL version)" + echo -n " ${FTL_VERSION}" > "${LOCAL_VERSION_FILE}" fi