-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4db0d0e
commit a094a44
Showing
8 changed files
with
96 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
BEGIN { num = 0; prev_line = 0; } | ||
/^[^[:space:]]/ { is_dns = /^dns:/; } | ||
/^[[:space:]]+bind_hosts:/ { is_dns_bh = 1; if (is_dns_bh && is_dns) prev_line = FNR; } | ||
/^[[:space:]]+- .+/ { | ||
if ((FNR - prev_line) == 1 && is_dns_bh) { addrs[num++] = $2; prev_line = FNR; } | ||
} | ||
/^[[:space:]]+port:/ { if (is_dns) port = $2; } | ||
END { | ||
for (i = 0; i < num; i++) { | ||
if (match(addrs[i], ":")) print "[" addrs[i] "]:" port; else print addrs[i] ":" port; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/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 log is an echo wrapper that writes to stderr if the caller requested | ||
# verbosity level greater than 0. Otherwise, it does nothing. | ||
log() { | ||
# if [ "$VERBOSE" -gt '0' ] | ||
# then | ||
echo "$1" 1>&2 | ||
# fi | ||
} | ||
|
||
home_dir="/opt/adguardhome" | ||
readonly home_dir | ||
|
||
filename="${home_dir}/conf/AdGuardHome.yaml" | ||
readonly filename | ||
|
||
if ! [ -f "$filename" ] | ||
then | ||
wget "http://127.0.0.1:3000" -O /dev/null || exit 1 | ||
|
||
exit 0 | ||
fi | ||
|
||
# Parse. | ||
|
||
help_dir="${home_dir}/scripts" | ||
readonly help_dir | ||
|
||
web_host=$(awk -f "${help_dir}/web-bind.awk" "$filename") | ||
readonly web_host | ||
|
||
dns_hosts=$(awk -f "${help_dir}/dns-bind.awk" "$filename") | ||
readonly dns_hosts | ||
|
||
if [ "$dns_hosts" == '' ] | ||
then | ||
log "No DNS bindings could be retrieved from $filename" | ||
|
||
exit 1 | ||
fi | ||
|
||
# TODO(e.burkov): Deal with 0 port. | ||
first=$(echo $dns_hosts | head -n 1) | ||
case $first | ||
in | ||
(*":0") | ||
log "0 port is not supported" | ||
|
||
exit 1 | ||
;; | ||
(*) | ||
# Go on. | ||
;; | ||
esac | ||
|
||
# Check | ||
|
||
wget "http://${web_host}" -O /dev/null || exit 1 | ||
|
||
echo "$dns_hosts" | while read -r host | ||
do | ||
nslookup -type=a localhost $host || exit 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/^bind_host:/ { host = $2 } | ||
/^bind_port:/ { port = $2 } | ||
END { if (match(host, ":")) print "[" host "]:" port; else print host ":" port; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters