bundles/unbound: automatically restart unbound if dns resolution fails for more than five minutes
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
35938ead04
commit
f0987ccb44
3 changed files with 29 additions and 0 deletions
25
bundles/unbound/files/unbound-auto-restart
Normal file
25
bundles/unbound/files/unbound-auto-restart
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
now="$(date +%s)"
|
||||
|
||||
resolved="$(dig +short kunbox.net)"
|
||||
|
||||
if [[ -n "$resolved" ]]
|
||||
then
|
||||
echo "$now" > /var/tmp/unbound_last_resolved
|
||||
exit 0
|
||||
fi
|
||||
|
||||
last_resolved="$(cat /var/tmp/unbound_last_resolved)"
|
||||
five_min_ago="$(expr $now - 300)"
|
||||
|
||||
if [[ "$last_resolved" -lt "$five_min_ago" ]]
|
||||
then
|
||||
systemctl restart unbound
|
||||
|
||||
# Write "in 25 minutes" timestamp to /var/tmp/unbound_last_resolved.
|
||||
# If resolving gets fixed by the restart, this will get re-written
|
||||
# on the next run of this script. If not, this script will restart
|
||||
# unbound again in half an hour (25min plus 5min grace time).
|
||||
echo "$(expr $now + 1500)" > /var/tmp/unbound_last_resolved
|
||||
fi
|
|
@ -6,6 +6,9 @@ files = {
|
|||
'svc_systemd:unbound:restart',
|
||||
},
|
||||
},
|
||||
'/usr/local/sbin/unbound-auto-restart': {
|
||||
'mode': '0755',
|
||||
},
|
||||
}
|
||||
|
||||
actions = {
|
||||
|
|
|
@ -13,6 +13,7 @@ defaults = {
|
|||
node.magic_number%24,
|
||||
node.magic_number%7,
|
||||
),
|
||||
'unbound-auto-restart': '* * * * * root /usr/local/sbin/unbound-auto-restart',
|
||||
},
|
||||
'nameservers': {
|
||||
'127.0.0.1',
|
||||
|
|
Loading…
Reference in a new issue