From c3bce0e7f2336ea33b33a3e95425da7eae653ed9 Mon Sep 17 00:00:00 2001 From: Xavier Maillard Date: Mon, 27 Sep 2021 12:35:47 +0200 Subject: [PATCH] kswitch: fix error handling of caascad-zones call --- pkgs/kswitch/default.nix | 2 +- pkgs/kswitch/kswitch.sh | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/kswitch/default.nix b/pkgs/kswitch/default.nix index 468accef..ae1be7ac 100644 --- a/pkgs/kswitch/default.nix +++ b/pkgs/kswitch/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation rec { pname = "kswitch"; - version = "1.8.4"; + version = "1.8.5"; buildInputs = [ makeWrapper ]; passAsFile = [ "buildCommand" ]; diff --git a/pkgs/kswitch/kswitch.sh b/pkgs/kswitch/kswitch.sh index 286b35b3..a140acd7 100755 --- a/pkgs/kswitch/kswitch.sh +++ b/pkgs/kswitch/kswitch.sh @@ -383,8 +383,9 @@ refresh_zones_or_cache() { refresh_zones() { log_debug "Refreshing caascad-zones..." local httpCode - httpCode="$(curl -w "%{response_code}" --connect-timeout 2 -s -o "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_URL}")" || { [ "${httpCode}" != "200" ] && log-error "Refreshing caascad-zones failed!" && return 1; } - mv "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_FILE}" || { log-error "Unable to write ${CAASCAD_ZONES_FILE}" && return 1; } + httpCode="$(curl -w "%{response_code}" --connect-timeout 2 -s -o "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_URL}")" + [ "${httpCode}" != "200" ] && { log-error "Refreshing caascad-zones failed!"; return 1; } + mv "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_FILE}" || { log-error "Unable to write ${CAASCAD_ZONES_FILE}"; return 1; } } zone_exists() { @@ -506,7 +507,7 @@ while (("$#")); do exit 1 ;; *) - [ "$zone" != "" ] && (log-error "too much arguments" && usage && exit 1) + [ "$zone" != "" ] && { log-error "too much arguments"; usage; exit 1; } zone=$1 shift ;; @@ -514,8 +515,8 @@ while (("$#")); do done exitNow=0 -[ "${cleanCache}" -eq 1 ] && clean_cache && exitNow=1 -[ "${forceUnlock}" -eq 1 ] && force_unlock && exitNow=1 +[ "${cleanCache}" -eq 1 ] && { clean_cache; exitNow=1; } +[ "${forceUnlock}" -eq 1 ] && { force_unlock; exitNow=1; } [ "${exitNow}" -eq 1 ] && exit 0 # Makes sure to use ~/.kube/config