mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-07 10:55:40 +00:00
Added from upstream repo.
Fixed missing Mysql client.
This commit is contained in:
parent
18d390ecea
commit
7bceb1262f
40
docker/PowerDNS-MySQL/Dockerfile
Normal file
40
docker/PowerDNS-MySQL/Dockerfile
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# PowerDNS Authoritative Server with MySQL backend
|
||||||
|
# https://www.powerdns.com
|
||||||
|
#
|
||||||
|
# The PowerDNS Authoritative Server is the only solution that enables
|
||||||
|
# authoritative DNS service from all major databases, including but not limited
|
||||||
|
# to MySQL, PostgreSQL, SQLite3, Oracle, Sybase, Microsoft SQL Server, LDAP and
|
||||||
|
# plain text files.
|
||||||
|
|
||||||
|
FROM winggundamth/ubuntu-base:trusty
|
||||||
|
MAINTAINER Jirayut Nimsaeng <w [at] winginfotech.net>
|
||||||
|
ENV FROM_BASE=trusty-20160503.1
|
||||||
|
|
||||||
|
# 1) Add PowerDNS repository https://repo.powerdns.com
|
||||||
|
# 2) Install PowerDNS server
|
||||||
|
# 3) Clean to reduce Docker image size
|
||||||
|
ARG APT_CACHER_NG
|
||||||
|
COPY build-files /build-files
|
||||||
|
RUN [ -n "$APT_CACHER_NG" ] && \
|
||||||
|
echo "Acquire::http::Proxy \"$APT_CACHER_NG\";" \
|
||||||
|
> /etc/apt/apt.conf.d/11proxy || true; \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y curl && \
|
||||||
|
curl https://repo.powerdns.com/FD380FBB-pub.asc | apt-key add - && \
|
||||||
|
echo 'deb [arch=amd64] http://repo.powerdns.com/ubuntu trusty-auth-40 main' \
|
||||||
|
> /etc/apt/sources.list.d/pdns-$(lsb_release -cs).list && \
|
||||||
|
mv /build-files/pdns-pin /etc/apt/preferences.d/pdns && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y pdns-server pdns-backend-mysql mysql-client && \
|
||||||
|
mv /build-files/pdns.mysql.conf /etc/powerdns/pdns.d/pdns.mysql.conf && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/* /etc/apt/apt.conf.d/11proxy /build-files \
|
||||||
|
/etc/powerdns/pdns.d/pdns.simplebind.conf
|
||||||
|
|
||||||
|
# 1) Copy Docker entrypoint script
|
||||||
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
|
||||||
|
EXPOSE 53/udp 53 8081
|
||||||
|
VOLUME ["/var/log", "/etc/powerdns"]
|
||||||
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
CMD ["/usr/sbin/pdns_server", "--guardian=yes"]
|
3
docker/PowerDNS-MySQL/build-files/pdns-pin
Normal file
3
docker/PowerDNS-MySQL/build-files/pdns-pin
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Package: pdns-*
|
||||||
|
Pin: origin repo.powerdns.com
|
||||||
|
Pin-Priority: 600
|
6
docker/PowerDNS-MySQL/build-files/pdns.mysql.conf
Normal file
6
docker/PowerDNS-MySQL/build-files/pdns.mysql.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
launch+=gmysql
|
||||||
|
gmysql-port=3306
|
||||||
|
gmysql-host=172.17.0.1
|
||||||
|
gmysql-password=CHANGEME
|
||||||
|
gmysql-user=powerdns
|
||||||
|
gmysql-dbname=powerdns
|
89
docker/PowerDNS-MySQL/docker-entrypoint.sh
Executable file
89
docker/PowerDNS-MySQL/docker-entrypoint.sh
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Author: Jirayut 'Dear' Nimsaeng
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PDNS_CONF_PATH="/etc/powerdns/pdns.conf"
|
||||||
|
PDNS_MYSQL_CONF_PATH="/etc/powerdns/pdns.d/pdns.mysql.conf"
|
||||||
|
PDNS_MYSQL_HOST="localhost"
|
||||||
|
PDNS_MYSQL_PORT="3306"
|
||||||
|
PDNS_MYSQL_USERNAME="powerdns"
|
||||||
|
PDNS_MYSQL_PASSWORD="$PDNS_DB_PASSWORD"
|
||||||
|
PDNS_MYSQL_DBNAME="powerdns"
|
||||||
|
|
||||||
|
if [ -z "$PDNS_DB_PASSWORD" ]; then
|
||||||
|
echo 'ERROR: PDNS_DB_PASSWORD environment variable not found'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure variables
|
||||||
|
if [ "$PDNS_DB_HOST" ]; then
|
||||||
|
PDNS_MYSQL_HOST="$PDNS_DB_HOST"
|
||||||
|
fi
|
||||||
|
if [ "$PDNS_DB_PORT" ]; then
|
||||||
|
PDNS_MYSQL_PORT="$PDNS_DB_PORT"
|
||||||
|
fi
|
||||||
|
if [ "$PDNS_DB_USERNAME" ]; then
|
||||||
|
PDNS_MYSQL_USERNAME="$PDNS_DB_USERNAME"
|
||||||
|
fi
|
||||||
|
if [ "$PDNS_DB_NAME" ]; then
|
||||||
|
PDNS_MYSQL_DBNAME="$PDNS_DB_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure mysql backend
|
||||||
|
sed -i \
|
||||||
|
-e "s/^gmysql-host=.*/gmysql-host=$PDNS_MYSQL_HOST/g" \
|
||||||
|
-e "s/^gmysql-port=.*/gmysql-port=$PDNS_MYSQL_PORT/g" \
|
||||||
|
-e "s/^gmysql-user=.*/gmysql-user=$PDNS_MYSQL_USERNAME/g" \
|
||||||
|
-e "s/^gmysql-password=.*/gmysql-password=$PDNS_MYSQL_PASSWORD/g" \
|
||||||
|
-e "s/^gmysql-dbname=.*/gmysql-dbname=$PDNS_MYSQL_DBNAME/g" \
|
||||||
|
$PDNS_MYSQL_CONF_PATH
|
||||||
|
|
||||||
|
if [ "$PDNS_SLAVE" != "1" ]; then
|
||||||
|
# Configure to be master
|
||||||
|
sed -i \
|
||||||
|
-e "s/^#\?\smaster=.*/master=yes/g" \
|
||||||
|
-e "s/^#\?\sslave=.*/slave=no/g" \
|
||||||
|
$PDNS_CONF_PATH
|
||||||
|
else
|
||||||
|
# Configure to be slave
|
||||||
|
sed -i \
|
||||||
|
-e "s/^#\?\smaster=.*/master=no/g" \
|
||||||
|
-e "s/^#\?\sslave=.*/slave=yes/g" \
|
||||||
|
$PDNS_CONF_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PDNS_API_KEY" ]; then
|
||||||
|
# Enable API
|
||||||
|
sed -i \
|
||||||
|
-e "s/^#\?\sapi=.*/api=yes/g" \
|
||||||
|
-e "s!^#\?\sapi-logfile=.*!api-logfile=/dev/stdout!g" \
|
||||||
|
-e "s/^#\?\sapi-key=.*/api-key=$PDNS_API_KEY/g" \
|
||||||
|
-e "s/^#\?\swebserver=.*/webserver=yes/g" \
|
||||||
|
-e "s/^#\?\swebserver-address=.*/webserver-address=0.0.0.0/g" \
|
||||||
|
$PDNS_CONF_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PDNS_WEBSERVER_ALLOW_FROM" ]; then
|
||||||
|
sed -i \
|
||||||
|
"s/^#\?\swebserver-allow-from=.*/webserver-allow-from=$PDNS_WEBSERVER_ALLOW_FROM/g" \
|
||||||
|
$PDNS_CONF_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
MYSQL_COMMAND="mysql -h $PDNS_MYSQL_HOST -P $PDNS_MYSQL_PORT -u $PDNS_MYSQL_USERNAME -p$PDNS_MYSQL_PASSWORD"
|
||||||
|
|
||||||
|
until $MYSQL_COMMAND -e ";" ; do
|
||||||
|
>&2 echo "MySQL is unavailable - sleeping"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
>&2 echo "MySQL is up - initial database if not exists"
|
||||||
|
MYSQL_CHECK_IF_HAS_TABLE="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '$PDNS_MYSQL_DBNAME';"
|
||||||
|
MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_HAS_TABLE")
|
||||||
|
if [ "$MYSQL_NUM_TABLE" -eq 0 ]; then
|
||||||
|
$MYSQL_COMMAND -D $PDNS_MYSQL_DBNAME < /usr/share/doc/pdns-backend-mysql/schema.mysql.sql
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start PowerDNS
|
||||||
|
exec "$@"
|
Loading…
Reference in New Issue
Block a user