From efd1de1f5e02540fc4ab296638443003d751d1ee Mon Sep 17 00:00:00 2001 From: ElevenNotes Date: Tue, 19 Sep 2023 10:14:16 +0200 Subject: [PATCH] added better rootdb handling --- README.md | 5 ++--- rootfs/usr/local/bin/entrypoint.sh | 5 +++++ rootfs/usr/local/bin/rootdb | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 89e7e6e..65c2aaa 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ docker run --name bind \ -d 11notes/bind:[tag] ``` -Update root db (will also update at container start) +Update root db (will update on start if does not exist) ```shell docker exec bind rootdb ``` @@ -34,5 +34,4 @@ docker exec bind rootdb * [Alpine Linux](https://alpinelinux.org) ## Tips -* Don't bind to ports < 1024 (requires root), use NAT/reverse proxy -* [Permanent Storage](https://github.com/11notes/alpine-docker-netshare) - Module to store permanent container data via NFS/CIFS and more \ No newline at end of file +* Don't bind to ports < 1024 (requires root), use NAT/reverse proxy \ No newline at end of file diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index 6bb6d69..ed0a0a3 100644 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -1,5 +1,10 @@ #!/bin/ash if [ -z "${1}" ]; then + + if [ ! -f "/bind/var/root.db" ]; then + rootdb + fi + set -- "named" \ -fg \ -c "/bind/etc/named.conf" \ diff --git a/rootfs/usr/local/bin/rootdb b/rootfs/usr/local/bin/rootdb index e55980f..e1abc20 100644 --- a/rootfs/usr/local/bin/rootdb +++ b/rootfs/usr/local/bin/rootdb @@ -1,2 +1,8 @@ #!/bin/ash - dig +bufsize=1200 +norec NS . @a.root-servers.net | egrep -v ';|^$' | egrep -v '\S.+AAAA.+|^$' | sort > /bind/var/root.db \ No newline at end of file + if [ ! -f "/bind/var/root.db" ]; then + ROOT_DB_NS=198.41.0.4 + else + ROOT_DB_NS=a.root-servers.net + fi + + dig +bufsize=1200 +norec NS . @${ROOT_DB_NS} | egrep -v ';|^$' | egrep -v '\S.+AAAA.+|^$' | sort > /bind/var/root.db \ No newline at end of file