Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Added PowerDNS parameter to allow requests based on env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
NIXKnight committed Sep 15, 2023
1 parent 7502844 commit f1ef84b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docker/powerdns/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

Expand Down
1 change: 1 addition & 0 deletions docker/powerdns/pdns.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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}
6 changes: 4 additions & 2 deletions docker/powerdns/pdns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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!"
Expand Down

0 comments on commit f1ef84b

Please sign in to comment.