#!/bin/sh
# shellcheck source=sv/acme-client-template/settings.sh
. ./settings.sh
case "$1" in
0) # Certificates were changed
	# Hiawatha needs everything in one file
	# shellcheck disable=SC2154
	cat "${SSLDIR}/${domain}/private/${domain}.pem" \
		"${SSLDIR}/${domain}/cert.pem" \
		>"${SSLDIR}/${domain}/private/hiawatha.crt"
	chmod 400 "${SSLDIR}/${domain}/private/hiawatha.crt"
	# Tell HTTP server to reload renewed certificates
	#sv check jail-http > /dev/null || exit 0
	#exec jexec http sv reload obhttpd
	#exec jexec http sv reload nginx
	;;
1) # Failure
	;;
2) # Certificates didn't change
	;;
esac
