From b7272412b463274e1b5d96e56f71bb5987867367 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 9 Apr 2023 13:41:48 +0200 Subject: [PATCH] fix if CA server is unavailable --- files/get_cert.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/files/get_cert.sh b/files/get_cert.sh index 892d2aa..7ff86ad 100755 --- a/files/get_cert.sh +++ b/files/get_cert.sh @@ -5,6 +5,13 @@ IFS=$'\n\t' eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost)"')" # TODO: Can this be done more eye-pleasingly? -CERT=$(ssh root@$CAHOST '/root/ca.sh host "'"$PUBKEY"'" "'"$HOST"'".dmz') +set +e +CERT=$(ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$CAHOST '/root/ca.sh host "'"$PUBKEY"'" "'"$HOST"'".dmz') +retval=$? +set -e + +if [ retval -neq 0 ]; then + CERT="error" +fi jq -n --arg cert "$CERT" '{"cert":$cert}'