mirror of
https://github.com/pschiffe/docker-pdns.git
synced 2025-01-18 11:01:14 +01:00
Tidy up scripts
This commit is contained in:
parent
15d3225d61
commit
e37b326748
7 changed files with 33 additions and 33 deletions
|
@ -234,9 +234,9 @@
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
env:
|
env:
|
||||||
PDNS_ADMIN_SQLA_DB_PASSWORD: "'my-secret-pw'"
|
PDNS_ADMIN_SQLA_DB_PASSWORD: 'my-secret-pw'
|
||||||
PDNS_VERSION: "4.8"
|
PDNS_VERSION: '4.8'
|
||||||
PDNS_API_KEY: "secret"
|
PDNS_API_KEY: 'secret'
|
||||||
tags:
|
tags:
|
||||||
- pdns-admin
|
- pdns-admin
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
environment:
|
environment:
|
||||||
- PDNS_ADMIN_SQLA_DB_PASSWORD='my-secret-pw'
|
- PDNS_ADMIN_SQLA_DB_PASSWORD=my-secret-pw
|
||||||
- PDNS_VERSION=4.8
|
- PDNS_VERSION=4.8
|
||||||
- PDNS_API_KEY=secret
|
- PDNS_API_KEY=secret
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -43,18 +43,18 @@ spec:
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
env:
|
env:
|
||||||
- name: PDNS_ADMIN_SQLA_DB_HOST
|
- name: PDNS_ADMIN_SQLA_DB_HOST
|
||||||
value: "'mariadb-pdns'"
|
value: "mariadb-pdns"
|
||||||
- name: PDNS_ADMIN_SQLA_DB_PORT
|
- name: PDNS_ADMIN_SQLA_DB_PORT
|
||||||
value: "'3306'"
|
value: "3306"
|
||||||
- name: PDNS_ADMIN_SQLA_DB_USER
|
- name: PDNS_ADMIN_SQLA_DB_USER
|
||||||
value: "'root'"
|
value: "root"
|
||||||
- name: PDNS_ADMIN_SQLA_DB_PASSWORD
|
- name: PDNS_ADMIN_SQLA_DB_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: pdns-admin-secret
|
name: pdns-admin-secret
|
||||||
key: quoted_mysql_password
|
key: quoted_mysql_password
|
||||||
- name: PDNS_ADMIN_SQLA_DB_NAME
|
- name: PDNS_ADMIN_SQLA_DB_NAME
|
||||||
value: "'pdnsadmin'"
|
value: "pdnsadmin"
|
||||||
- name: PDNS_API_URL
|
- name: PDNS_API_URL
|
||||||
value: "http://master-api-pdns:8081/"
|
value: "http://master-api-pdns:8081/"
|
||||||
- name: PDNS_VERSION
|
- name: PDNS_VERSION
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
subvars --prefix 'PDNS_ADMIN_STATIC_' < /pdns-nginx.conf.tpl > /etc/nginx/nginx.conf
|
subvars --prefix 'PDNS_ADMIN_STATIC_' < '/pdns-nginx.conf.tpl' > '/etc/nginx/nginx.conf'
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
@ -32,7 +32,7 @@ PDNS_ADMIN_SECRET_KEY="$(cat /root/secret-key)"
|
||||||
|
|
||||||
export PDNS_ADMIN_SECRET_KEY
|
export PDNS_ADMIN_SECRET_KEY
|
||||||
|
|
||||||
subvars --prefix 'PDNS_ADMIN_' < /config.py.tpl > /opt/powerdns-admin/powerdnsadmin/default_config.py
|
subvars --prefix 'PDNS_ADMIN_' < '/config.py.tpl' > '/opt/powerdns-admin/powerdnsadmin/default_config.py'
|
||||||
|
|
||||||
# Initialize DB if needed
|
# Initialize DB if needed
|
||||||
MYSQL_COMMAND="mysql -h ${PDNS_ADMIN_SQLA_DB_HOST} -P ${PDNS_ADMIN_SQLA_DB_PORT} -u ${PDNS_ADMIN_SQLA_DB_USER} -p${PDNS_ADMIN_SQLA_DB_PASSWORD}"
|
MYSQL_COMMAND="mysql -h ${PDNS_ADMIN_SQLA_DB_HOST} -P ${PDNS_ADMIN_SQLA_DB_PORT} -u ${PDNS_ADMIN_SQLA_DB_USER} -p${PDNS_ADMIN_SQLA_DB_PASSWORD}"
|
||||||
|
@ -47,14 +47,14 @@ $MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_ADMIN_SQLA_DB_NAME}"
|
||||||
flask db upgrade
|
flask db upgrade
|
||||||
|
|
||||||
# initial settings if not available in the DB
|
# initial settings if not available in the DB
|
||||||
$MYSQL_COMMAND ${PDNS_ADMIN_SQLA_DB_NAME} -e "INSERT INTO setting (name, value) SELECT * FROM (SELECT 'pdns_api_url', '${PDNS_API_URL//[\'\"]}') AS tmp WHERE NOT EXISTS (SELECT name FROM setting WHERE name = 'pdns_api_url') LIMIT 1;"
|
$MYSQL_COMMAND "${PDNS_ADMIN_SQLA_DB_NAME}" -e "INSERT INTO setting (name, value) SELECT * FROM (SELECT 'pdns_api_url', '${PDNS_API_URL//[\'\"]}') AS tmp WHERE NOT EXISTS (SELECT name FROM setting WHERE name = 'pdns_api_url') LIMIT 1;"
|
||||||
$MYSQL_COMMAND ${PDNS_ADMIN_SQLA_DB_NAME} -e "INSERT INTO setting (name, value) SELECT * FROM (SELECT 'pdns_api_key', '${PDNS_API_KEY//[\'\"]}') AS tmp WHERE NOT EXISTS (SELECT name FROM setting WHERE name = 'pdns_api_key') LIMIT 1;"
|
$MYSQL_COMMAND "${PDNS_ADMIN_SQLA_DB_NAME}" -e "INSERT INTO setting (name, value) SELECT * FROM (SELECT 'pdns_api_key', '${PDNS_API_KEY//[\'\"]}') AS tmp WHERE NOT EXISTS (SELECT name FROM setting WHERE name = 'pdns_api_key') LIMIT 1;"
|
||||||
$MYSQL_COMMAND ${PDNS_ADMIN_SQLA_DB_NAME} -e "INSERT INTO setting (name, value) SELECT * FROM (SELECT 'pdns_version', '${PDNS_VERSION//[\'\"]}') AS tmp WHERE NOT EXISTS (SELECT name FROM setting WHERE name = 'pdns_version') LIMIT 1;"
|
$MYSQL_COMMAND "${PDNS_ADMIN_SQLA_DB_NAME}" -e "INSERT INTO setting (name, value) SELECT * FROM (SELECT 'pdns_version', '${PDNS_VERSION//[\'\"]}') AS tmp WHERE NOT EXISTS (SELECT name FROM setting WHERE name = 'pdns_version') LIMIT 1;"
|
||||||
|
|
||||||
# update pdns api settings if env changed
|
# update pdns api settings if env changed
|
||||||
$MYSQL_COMMAND ${PDNS_ADMIN_SQLA_DB_NAME} -e "UPDATE setting SET value='${PDNS_API_URL//[\'\"]}' WHERE name='pdns_api_url';"
|
$MYSQL_COMMAND "${PDNS_ADMIN_SQLA_DB_NAME}" -e "UPDATE setting SET value='${PDNS_API_URL//[\'\"]}' WHERE name='pdns_api_url';"
|
||||||
$MYSQL_COMMAND ${PDNS_ADMIN_SQLA_DB_NAME} -e "UPDATE setting SET value='${PDNS_API_KEY//[\'\"]}' WHERE name='pdns_api_key';"
|
$MYSQL_COMMAND "${PDNS_ADMIN_SQLA_DB_NAME}" -e "UPDATE setting SET value='${PDNS_API_KEY//[\'\"]}' WHERE name='pdns_api_key';"
|
||||||
$MYSQL_COMMAND ${PDNS_ADMIN_SQLA_DB_NAME} -e "UPDATE setting SET value='${PDNS_VERSION//[\'\"]}' WHERE name='pdns_version';"
|
$MYSQL_COMMAND "${PDNS_ADMIN_SQLA_DB_NAME}" -e "UPDATE setting SET value='${PDNS_VERSION//[\'\"]}' WHERE name='pdns_version';"
|
||||||
|
|
||||||
mkdir -p /run/uwsgi
|
mkdir -p /run/uwsgi
|
||||||
chown uwsgi: /run/uwsgi
|
chown uwsgi: /run/uwsgi
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -eu
|
||||||
|
|
||||||
# Configure base vars
|
# Configure base vars
|
||||||
: "${PDNS_local_port:=53}"
|
: "${PDNS_local_port:=53}"
|
||||||
|
@ -18,9 +18,9 @@ elif [ -f /etc/alpine-release ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create config file from template
|
# Create config file from template
|
||||||
subvars --prefix 'PDNS_' < /recursor.conf.tpl > $config_file
|
subvars --prefix 'PDNS_' < '/recursor.conf.tpl' > "${config_file}"
|
||||||
|
|
||||||
# Fix config file ownership
|
# Fix config file ownership
|
||||||
chown ${pdns_user}: $config_file
|
chown "${pdns_user}:" "${config_file}"
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -eu
|
||||||
|
|
||||||
# Configure mysql env vars
|
# Configure mysql env vars
|
||||||
: "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}"
|
: "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}"
|
||||||
|
@ -14,23 +14,23 @@ fi
|
||||||
|
|
||||||
# use first part of node name as database name suffix
|
# use first part of node name as database name suffix
|
||||||
if [ "${NODE_NAME:-}" ]; then
|
if [ "${NODE_NAME:-}" ]; then
|
||||||
NODE_NAME=$(echo ${NODE_NAME} | sed -e 's/\..*//' -e 's/-//')
|
NODE_NAME=$(echo "${NODE_NAME}" | sed -e 's/\..*//' -e 's/-//')
|
||||||
PDNS_gmysql_dbname="${PDNS_gmysql_dbname}${NODE_NAME}"
|
PDNS_gmysql_dbname="${PDNS_gmysql_dbname}${NODE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname
|
export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname
|
||||||
|
|
||||||
EXTRA=""
|
|
||||||
|
EXTRA=''
|
||||||
|
|
||||||
# Password Auth
|
# Password Auth
|
||||||
if [ "${PDNS_gmysql_password}" != "" ]; then
|
if [ "${PDNS_gmysql_password}" ]; then
|
||||||
EXTRA="${EXTRA} -p${PDNS_gmysql_password}"
|
EXTRA="${EXTRA} -p${PDNS_gmysql_password}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Allow socket connections
|
# Allow socket connections
|
||||||
if [ "${PDNS_gmysql_socket:-}" != "" ]; then
|
if [ "${PDNS_gmysql_socket:-}" ]; then
|
||||||
export PDNS_gmysql_host="localhost"
|
export PDNS_gmysql_host='localhost'
|
||||||
EXTRA="${EXTRA} --socket=${PDNS_gmysql_socket}"
|
EXTRA="${EXTRA} --socket=${PDNS_gmysql_socket}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -61,17 +61,17 @@ if [ "$MYSQL_NUM_TABLE" -eq 0 ]; then
|
||||||
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" < /usr/share/doc/pdns/4.3.0_to_4.7.0_schema.mysql.sql
|
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" < /usr/share/doc/pdns/4.3.0_to_4.7.0_schema.mysql.sql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${PDNS_superslave:-no}" == "yes" ]; then
|
if [ "${PDNS_superslave:-no}" = 'yes' ]; then
|
||||||
# Configure supermasters if needed
|
# Configure supermasters if needed
|
||||||
if [ "${SUPERMASTER_IPS:-}" ]; then
|
if [ "${SUPERMASTER_IPS:-}" ]; then
|
||||||
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e "TRUNCATE supermasters;"
|
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e 'TRUNCATE supermasters;'
|
||||||
MYSQL_INSERT_SUPERMASTERS=''
|
MYSQL_INSERT_SUPERMASTERS=''
|
||||||
if [ "${SUPERMASTER_COUNT:-0}" == "0" ]; then
|
if [ "${SUPERMASTER_COUNT:-0}" -eq 0 ]; then
|
||||||
SUPERMASTER_COUNT=10
|
SUPERMASTER_COUNT=10
|
||||||
fi
|
fi
|
||||||
i=1; while [ $i -le ${SUPERMASTER_COUNT} ]; do
|
i=1; while [ $i -le "${SUPERMASTER_COUNT}" ]; do
|
||||||
SUPERMASTER_HOST=$(echo ${SUPERMASTER_HOSTS:-} | awk -v col="$i" '{ print $col }')
|
SUPERMASTER_HOST=$(echo "${SUPERMASTER_HOSTS:-}" | awk -v col="$i" '{ print $col }')
|
||||||
SUPERMASTER_IP=$(echo ${SUPERMASTER_IPS} | awk -v col="$i" '{ print $col }')
|
SUPERMASTER_IP=$(echo "${SUPERMASTER_IPS}" | awk -v col="$i" '{ print $col }')
|
||||||
if [ -z "${SUPERMASTER_HOST:-}" ]; then
|
if [ -z "${SUPERMASTER_HOST:-}" ]; then
|
||||||
SUPERMASTER_HOST=$(hostname -f)
|
SUPERMASTER_HOST=$(hostname -f)
|
||||||
fi
|
fi
|
||||||
|
@ -85,6 +85,6 @@ if [ "${PDNS_superslave:-no}" == "yes" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create config file from template
|
# Create config file from template
|
||||||
subvars --prefix 'PDNS_' < /pdns.conf.tpl > /etc/pdns/pdns.conf
|
subvars --prefix 'PDNS_' < '/pdns.conf.tpl' > '/etc/pdns/pdns.conf'
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
Loading…
Reference in a new issue