fix if CA server is unavailable

This commit is contained in:
Pim Kunis 2023-04-09 13:41:48 +02:00
parent 013fc774c0
commit b7272412b4

View file

@ -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}'