Skip to content

Instantly share code, notes, and snippets.

@casebeer
Created May 15, 2024 20:34
Show Gist options
  • Save casebeer/2b91d2488646b6a801cf58184b999297 to your computer and use it in GitHub Desktop.
Save casebeer/2b91d2488646b6a801cf58184b999297 to your computer and use it in GitHub Desktop.
Flush Unbound DNS local auth-zones and their cached entries after updating zonefiles (and serial numbers).
#!/bin/bash
# set path to directory holding docker-compose.yaml
#dockerComposeRoot=
if [ -z "$dockerComposeRoot" ]; then
echo "ERROR: Set dockerComposeRoot before calling $0" >&2
exit 1
fi
(
cd "$dockerComposeRoot"
# read via FD3 to avoid disruption from processing of stdin/stdout by loop contents
while read -u 3 zone ; do
echo "Flushing zone ${zone}" >&2
docker-compose exec -T unbound unbound-control -s 127.0.0.1 auth_zone_reload "$zone"
docker-compose exec -T unbound unbound-control -s 127.0.0.1 flush_zone "$zone"
done 3< <(docker-compose exec -T unbound unbound-control -s 127.0.0.1 list_auth_zones | cut -f 1)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment