Skip to content

Commit 8126520

Browse files
cursoragentjeboehm
andcommitted
Refactor healthcheck script to use dig for TCP checks
Co-authored-by: j.boehm <[email protected]>
1 parent b2bb27a commit 8126520

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

target/unbound/rootfs/usr/local/bin/healthcheck.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/sh
22
set -e
33

4-
# 1. test connection to 0.0.0.0:53 (UDP via dig) and TCP via nc
4+
# UDP check
55
if ! dig @127.0.0.1 -p 53 github.com +time=2 +tries=1 +short >/dev/null 2>&1; then
6-
echo "Healthcheck failed: dig to 127.0.0.1:53"
6+
echo "Healthcheck failed: dig UDP to 127.0.0.1:53"
77
exit 1
88
fi
99

10-
if ! nc -z 0.0.0.0 53; then
11-
echo "Healthcheck failed: cannot connect to 0.0.0.0:53 (TCP)"
10+
# TCP check (no nc dependency)
11+
if ! dig +tcp @127.0.0.1 -p 53 github.com +time=2 +tries=1 +short >/dev/null 2>&1; then
12+
echo "Healthcheck failed: dig TCP to 127.0.0.1:53"
1213
exit 1
1314
fi
1415

0 commit comments

Comments
 (0)