diff options
author | tv <tv@krebsco.de> | 2015-05-20 21:26:55 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2015-05-20 21:26:55 +0200 |
commit | 4fae1fdb0d2b7769a8ba6468eee79d109c00d8ab (patch) | |
tree | 02857c0b284c8618af38677c4cb66fe84e1bf1b7 | |
parent | 25d4a34da8b9573fd3ff162645a2ebe6c57e149b (diff) |
lib/cac.sh cac_listservers: check response status
-rwxr-xr-x | infest | 8 | ||||
-rw-r--r-- | lib/cac.sh | 13 | ||||
-rwxr-xr-x | networking-configuration | 8 |
3 files changed, 10 insertions, 19 deletions
@@ -21,14 +21,6 @@ nix_find_sha1sum=86f8775bd4f0841edd4c816df861cebf509d58c3 main() { listservers=$(cac_listservers) - listserversstatus=$(echo $listservers | jq -r .status) - case $listserversstatus in - ok) : ;; - *) - echo $0: bad listservers status: $listserversstatus >&2 - exit 1 - esac - config=$(echo $listservers \ | jq -r ".data|map(select(.servername == \"$cac_servername\"))[]") @@ -1,8 +1,15 @@ . ./lib/url.sh -cac_listservers() { - _cac_get_api_v1 listservers -} +cac_listservers() {( + listservers=$(_cac_get_api_v1 listservers) + status=$(echo "$listservers" | jq -r .status) + if [ "$status" = ok ]; then + echo "$listservers" + else + echo "$0: bad listservers status: $status" >&2 + exit 1 + fi +)} cac_listtasks() { _cac_get_api_v1 listtasks diff --git a/networking-configuration b/networking-configuration index 4b7a85d..b9725c7 100755 --- a/networking-configuration +++ b/networking-configuration @@ -22,14 +22,6 @@ hostname=$2 main() { listservers=$(cac_listservers) - listserversstatus=$(echo $listservers | jq -r .status) - case $listserversstatus in - ok) : ;; - *) - echo $0: bad listservers status: $listserversstatus >&2 - exit 1 - esac - config=$(echo $listservers \ | jq -r ".data|map(select(.servername == \"$cac_servername\"))[]") |