From f1ef84b778396326692cd5afd8964122175fa3a7 Mon Sep 17 00:00:00 2001 From: Saad Ali Date: Fri, 15 Sep 2023 23:19:50 +0500 Subject: [PATCH] Added PowerDNS parameter to allow requests based on env vars --- docker/powerdns/Dockerfile | 4 ++-- docker/powerdns/pdns.conf.template | 1 + docker/powerdns/pdns.sh | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docker/powerdns/Dockerfile b/docker/powerdns/Dockerfile index ba39756..75ed925 100644 --- a/docker/powerdns/Dockerfile +++ b/docker/powerdns/Dockerfile @@ -17,8 +17,8 @@ RUN set -eux; \ curl https://repo.powerdns.com/FD380FBB-pub.asc | tee /etc/apt/keyrings/pdns-pub.asc; \ apt-get update; \ apt-get -y install --no-install-recommends pdns-server pdns-backend-mysql pdns-recursor; \ - mkdir -p /etc/powerdns/template /var/run/pdns-recursor; \ - chown -R pdns:pdns /etc/powerdns /var/run/pdns-recursor; \ + mkdir -p /etc/powerdns/template /var/run/pdns-recursor /var/run/pdns; \ + chown -R pdns:pdns /etc/powerdns /var/run/pdns-recursor /var/run/pdns; \ apt-get clean all; \ rm -rf /var/lib/apt/lists/* diff --git a/docker/powerdns/pdns.conf.template b/docker/powerdns/pdns.conf.template index 802d573..a7818f6 100644 --- a/docker/powerdns/pdns.conf.template +++ b/docker/powerdns/pdns.conf.template @@ -20,3 +20,4 @@ api-key=${PDNS_API_KEY} webserver=yes webserver-address=${PDNS_API_ADDRESS} webserver-port=${PDNS_API_PORT} +webserver-allow-from=${PDNS_API_ALLOW_FROM} diff --git a/docker/powerdns/pdns.sh b/docker/powerdns/pdns.sh index f0cb006..ec9e12e 100755 --- a/docker/powerdns/pdns.sh +++ b/docker/powerdns/pdns.sh @@ -17,7 +17,9 @@ function check_vars { # Function to generate PowerDNS Server configuration function generate_pdns_config { - check_vars PDNS_MYSQL_HOST PDNS_MYSQL_USERNAME PDNS_MYSQL_PASSWORD PDNS_MYSQL_DATABASE PDNS_LOCAL_PORT PDNS_API_KEY PDNS_API_ADDRESS PDNS_API_PORT + : ${PDNS_API_ALLOW_FROM:=127.0.0.1} + export PDNS_API_ALLOW_FROM + check_vars PDNS_MYSQL_HOST PDNS_MYSQL_USERNAME PDNS_MYSQL_PASSWORD PDNS_MYSQL_DATABASE PDNS_LOCAL_PORT PDNS_API_KEY PDNS_API_ADDRESS PDNS_API_PORT PDNS_API_ALLOW_FROM envsubst < /etc/powerdns/template/pdns.conf.template > /etc/powerdns/pdns.conf } @@ -39,7 +41,7 @@ function start_pdns { if [[ -z "$TABLE_CHECK" ]]; then echo "Database not initialized. Initializing..." mysql -h $PDNS_MYSQL_HOST -u $PDNS_MYSQL_USERNAME -p$PDNS_MYSQL_PASSWORD -D $PDNS_MYSQL_DATABASE < /usr/share/pdns-backend-mysql/schema/schema.mysql.sql - if [ $? eq 0 ] ; then + if [ $? -eq 0 ] ; then echo "Database initialized successfully." else echo "Error: Database initialization Failed!"