From 7ae0b207fc64c306a57c2fadfa0209dadd655dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sun, 20 Oct 2024 09:34:15 +0200 Subject: [PATCH] Exit 1 if update script failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/update.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index e4f784ba..72ba294e 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -38,10 +38,13 @@ GitCheckUpdateAvail() { local curBranch directory="${1}" curdir=$PWD - cd "${directory}" || return + cd "${directory}" || exit 1 # Fetch latest changes in this repo - git fetch --quiet origin + if ! git fetch --quiet origin ; then + echo -e "\\n ${COL_LIGHT_RED}Error: Unable to update local repository. Contact Pi-hole Support.${COL_NC}" + exit 1 + fi # Check current branch. If it is master, then check for the latest available tag instead of latest commit. curBranch=$(git rev-parse --abbrev-ref HEAD) @@ -71,17 +74,17 @@ GitCheckUpdateAvail() { echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support" echo -e " Additional debugging output:${COL_NC}" git status - exit + exit 1 fi if [[ "${#REMOTE}" == 0 ]]; then echo -e "\\n ${COL_LIGHT_RED}Error: Remote revision could not be obtained, please contact Pi-hole Support" echo -e " Additional debugging output:${COL_NC}" git status - exit + exit 1 fi # Change back to original directory - cd "${curdir}" || exit + cd "${curdir}" || exit 1 if [[ "${LOCAL}" != "${REMOTE}" ]]; then # Local branch is behind remote branch -> Update