17 lines
394 B
Bash
Executable file
17 lines
394 B
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost)"')"
|
|
|
|
# TODO: Can this be done more eye-pleasingly?
|
|
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}'
|