mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-03-30 05:59:05 +03:00
Merge in DNS/adguard-home from 3290-docker-healthcheck to master Updates #3290. Squashed commit of the following: commit 3ac8f26c1c22855d973910fd13c096776aa8dfa6 Merge: bc17565f0df32601
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Mar 27 01:09:03 2023 +0500 Merge branch 'master' into 3290-docker-healthcheck commit bc17565fcb5acba68129734450fb08b4fe341771 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Sun Mar 26 18:04:08 2023 +0500 all: fix script commit e150fee8025dacdc5aa1d12916d1f42e89216156 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Sun Mar 26 17:18:12 2023 +0500 all: imp naming commit 26b6448d10af39f8363eadd962af228a9d4ae51d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Sun Mar 26 03:13:47 2023 +0500 all: support https web commit b5c09ce8b2ac52d6e47a00f76125bee229f616a0 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Sat Mar 25 20:03:45 2023 +0500 all: imp scripts fmt, naming commit 8c3798c46974e48cc0c379c2ecc46a6d8d54164b Merge: e33b0c5cfb7b8bba
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Sat Mar 25 00:25:38 2023 +0500 Merge branch 'master' into 3290-docker-healthcheck commit e33b0c5cbfe5a28b29734c9ceee046b0f82a0efe Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Mar 24 16:47:26 2023 +0500 all: fix docs commit 57bfd898b9c468b2b72eba06294ed5e5e0226c20 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Mar 24 16:44:40 2023 +0500 dnsforward: add special-use domain handling commit f04ae13f441a25d0b4dc1359b328552f7507fc23 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Mar 24 16:05:10 2023 +0500 all: imp code commit 32f150f88390320d2da85b54e27f6c751eccb851 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Mar 24 04:19:10 2023 +0500 all: mv Dockerfile, log changes commit a094a44ccfa26988f0e71f19288e08b26e255e2b Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Mar 24 04:04:27 2023 +0500 all: finish scripts, imp names commit 4db0d0e7cb7ed69030994bc1b579534dd2c3395d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Mar 23 18:33:47 2023 +0500 docker: add script and awk program
83 lines
1.6 KiB
Bash
Executable file
83 lines
1.6 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# AdGuard Home Docker healthcheck script
|
|
|
|
# Exit the script if a pipeline fails (-e), prevent accidental filename
|
|
# expansion (-f), and consider undefined variables as errors (-u).
|
|
set -e -f -u
|
|
|
|
# Function error_exit is an echo wrapper that writes to stderr and stops the
|
|
# script execution with code 1.
|
|
error_exit() {
|
|
echo "$1" 1>&2
|
|
|
|
exit 1
|
|
}
|
|
|
|
agh_dir="/opt/adguardhome"
|
|
readonly agh_dir
|
|
|
|
filename="${agh_dir}/conf/AdGuardHome.yaml"
|
|
readonly filename
|
|
|
|
if ! [ -f "$filename" ]
|
|
then
|
|
wget "http://127.0.0.1:3000" -O /dev/null -q || exit 1
|
|
|
|
exit 0
|
|
fi
|
|
|
|
help_dir="${agh_dir}/scripts"
|
|
readonly help_dir
|
|
|
|
# Parse web host
|
|
|
|
web_url="$( awk -f "${help_dir}/web-bind.awk" "$filename" )"
|
|
readonly web_url
|
|
|
|
if [ "$web_url" = '' ]
|
|
then
|
|
error_exit "no web bindings could be retrieved from $filename"
|
|
fi
|
|
|
|
# TODO(e.burkov): Deal with 0 port.
|
|
case "$web_url"
|
|
in
|
|
(*':0')
|
|
error_exit '0 in web port is not supported by healthcheck'
|
|
;;
|
|
(*)
|
|
# Go on.
|
|
;;
|
|
esac
|
|
|
|
# Parse DNS hosts
|
|
|
|
dns_hosts="$( awk -f "${help_dir}/dns-bind.awk" "$filename" )"
|
|
readonly dns_hosts
|
|
|
|
if [ "$dns_hosts" = '' ]
|
|
then
|
|
error_exit "no DNS bindings could be retrieved from $filename"
|
|
fi
|
|
|
|
# TODO(e.burkov): Deal with 0 port.
|
|
case "$( echo "$dns_hosts" | head -n 1 )"
|
|
in
|
|
(*':0')
|
|
error_exit '0 in DNS port is not supported by healthcheck'
|
|
;;
|
|
(*)
|
|
# Go on.
|
|
;;
|
|
esac
|
|
|
|
# Check
|
|
|
|
wget "$web_url" -O /dev/null -q || exit 1
|
|
|
|
echo "$dns_hosts" | while read -r host
|
|
do
|
|
nslookup -type=a healthcheck.adguardhome.test. "$host" > /dev/null ||\
|
|
error_exit "nslookup failed for $host"
|
|
done
|