unbound/healthcheck.sh

13 lines
374 B
Bash
Raw Permalink Normal View History

#!/bin/sh
2023-11-07 20:43:14 +00:00
HEALTHCHECK_RECORD=healthcheck.unbound
EXPECTED_VALUE=127.0.0.1
RESOLVED_IP=$(nslookup "${HEALTHCHECK_RECORD}" 127.0.0.1 | awk -F':' '/^Address: / { matched = 1 } matched { print $2}' | xargs)
if [ "${RESOLVED_IP}" != "${EXPECTED_VALUE}" ]; then
echo "[ERR] ${HEALTHCHECK_RECORD} lookup failed"
exit 1
fi
echo "[OK] ${HEALTHCHECK_RECORD} == ${RESOLVED_IP}"