All checks were successful
nixos / nixos (push) Successful in 1m3s
The test pair served the move to NixOS, which is done. Its overlays, dummy secrets and sops recipients go; the rules for testing on a copy of production stay in nixos/README.md, and git log finds the overlay if it is needed again. Options that existed only for it (alert address, Loki bucket, extra cert-push keys) are inlined, and comments still pointing at Ansible or MIGRATION.md are corrected. The tofu README now spells out the state bucket bootstrap: the bucket is a resource in the state it holds, so a new project needs one local apply first. The bucket gets prevent_destroy for the same reason. Assisted-by: Claude:opus-5-5
31 lines
1.3 KiB
Shell
31 lines
1.3 KiB
Shell
# Forced command of the xmpp-cert-sync key from asxpio-ops: read a
|
|
# certificate chain + key on stdin, check it, install it as
|
|
# certs/<name>.pem for ejabberd (which picks the matching file per
|
|
# domain) and reload.
|
|
set -eu
|
|
umask 022
|
|
name=${SSH_ORIGINAL_COMMAND:-}
|
|
case "$name" in
|
|
asxp.io|*.asxp.io) ;;
|
|
*) echo "refusing certificate name '$name'" >&2; exit 1 ;;
|
|
esac
|
|
case "$name" in *[!a-z0-9.-]*) echo "bad name" >&2; exit 1 ;; esac
|
|
dir=/opt/xmpp/state/certs
|
|
tmp=$(mktemp "$dir/.incoming.XXXXXX")
|
|
trap 'rm -f "$tmp"' EXIT
|
|
head -c 65536 > "$tmp"
|
|
# Valid for at least another day, for this name, with its matching key
|
|
openssl x509 -in "$tmp" -noout -checkend 86400 >/dev/null
|
|
openssl x509 -in "$tmp" -noout -checkhost "$name" | grep -q "does match"
|
|
cert_pub=$(openssl x509 -in "$tmp" -noout -pubkey | sha256sum)
|
|
key_pub=$(openssl pkey -in "$tmp" -pubout | sha256sum)
|
|
[ "$cert_pub" = "$key_pub" ] || { echo "key does not match certificate" >&2; exit 1; }
|
|
chmod 0644 "$tmp"
|
|
mv "$tmp" "$dir/$name.pem"
|
|
trap - EXIT
|
|
# Not running during a restore: ejabberd reads the
|
|
# file at its next start
|
|
if podman container exists xmpp-ejabberd; then
|
|
podman exec xmpp-ejabberd ejabberdctl reload_config
|
|
fi
|
|
logger -t xmpp-cert-install "installed $name.pem, $(openssl x509 -in "$dir/$name.pem" -noout -enddate)"
|