2023-03-20 06:59:00 +00:00
|
|
|
#!/bin/sh
|
2022-12-07 14:44:07 +00:00
|
|
|
|
|
|
|
HOST="localhost"
|
2024-03-04 10:47:18 +00:00
|
|
|
PORT=$HEALTHCHECK_PORT
|
|
|
|
|
|
|
|
if [ -z "$HEALTHCHECK_PORT" ]; then
|
2024-04-07 07:49:00 +00:00
|
|
|
# check all the TCP listening sockets, filter the dragonfly process, and fetch the port.
|
|
|
|
# For cases when dragonfly opens multiple ports, we filter with tail to choose one of them.
|
2024-09-04 14:34:35 +00:00
|
|
|
PORT=$(su dfly -c "netstat -tlnp" | grep "1/dragonfly" | grep -oE ':[0-9]+' | cut -c2- | tail -n 1)
|
2024-03-04 10:47:18 +00:00
|
|
|
fi
|
2022-12-07 14:44:07 +00:00
|
|
|
|
2023-01-05 11:28:29 +00:00
|
|
|
# If we're running with TLS enabled, utilise OpenSSL for the check
|
|
|
|
if [ -f "/etc/dragonfly/tls/ca.crt" ]
|
|
|
|
then
|
|
|
|
_healthcheck="openssl s_client -connect ${HOST}:${PORT} -CAfile /etc/dragonfly/tls/ca.crt -quiet -no_ign_eof"
|
|
|
|
else
|
|
|
|
_healthcheck="nc -q1 $HOST $PORT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo PING | ${_healthcheck}
|
2022-12-07 14:44:07 +00:00
|
|
|
|
|
|
|
exit $?
|