Files

19 lines
855 B
Bash
Executable File

#!/bin/sh
# rationale: the preferred method for automated cert updates is to have virtual hosts with required
# hostnames and certs automatically updated with ingress and cert manager.
# This script checks if the certs in the container are updated and if not, it fails the healthcheck to
# trigger a restart of the container with the new certs. If the certs are updated, it checks if prosody
#is running and healthy by checking if the TCP port 5582 is open and responsive.
if [ -f /etc/tls-update/tls.crt ]; then
OLDHASH=$(md5sum /etc/prosody/certs/prosody-ssl.pem | awk '{print $1}')
NEWHASH=$(md5sum /etc/tls-update/tls.crt | awk '{print $1}')
if [ "x$OLDHASH" != "x$NEWHASH" ]; then
# cert in secret is changed - fail healthcheck to restart with new cert
exit 2
fi
fi
/usr/lib/nagios/plugins/check_tcp -H 127.0.0.1 -p 5582 -w 6 -c 3