Skip to content

Commit

Permalink
Tidy up scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pschiffe committed Dec 19, 2023
1 parent 15d3225 commit e37b326
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions ansible-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@
volumes:
- /etc/localtime:/etc/localtime:ro
env:
PDNS_ADMIN_SQLA_DB_PASSWORD: "'my-secret-pw'"
PDNS_VERSION: "4.8"
PDNS_API_KEY: "secret"
PDNS_ADMIN_SQLA_DB_PASSWORD: 'my-secret-pw'
PDNS_VERSION: '4.8'
PDNS_API_KEY: 'secret'
tags:
- pdns-admin

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ services:
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
- PDNS_ADMIN_SQLA_DB_PASSWORD='my-secret-pw'
- PDNS_ADMIN_SQLA_DB_PASSWORD=my-secret-pw
- PDNS_VERSION=4.8
- PDNS_API_KEY=secret
depends_on:
Expand Down
8 changes: 4 additions & 4 deletions examples/kubernetes/admin-dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ spec:
imagePullPolicy: IfNotPresent
env:
- name: PDNS_ADMIN_SQLA_DB_HOST
value: "'mariadb-pdns'"
value: "mariadb-pdns"
- name: PDNS_ADMIN_SQLA_DB_PORT
value: "'3306'"
value: "3306"
- name: PDNS_ADMIN_SQLA_DB_USER
value: "'root'"
value: "root"
- name: PDNS_ADMIN_SQLA_DB_PASSWORD
valueFrom:
secretKeyRef:
name: pdns-admin-secret
key: quoted_mysql_password
- name: PDNS_ADMIN_SQLA_DB_NAME
value: "'pdnsadmin'"
value: "pdnsadmin"
- name: PDNS_API_URL
value: "http://master-api-pdns:8081/"
- name: PDNS_VERSION
Expand Down
2 changes: 1 addition & 1 deletion pdns-admin-static-ngoduykhanh/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

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 "$@"
14 changes: 7 additions & 7 deletions pdns-admin-uwsgi-ngoduykhanh/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PDNS_ADMIN_SECRET_KEY="$(cat /root/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
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}"
Expand All @@ -47,14 +47,14 @@ $MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_ADMIN_SQLA_DB_NAME}"
flask db upgrade

# 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_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_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_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
$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_VERSION//[\'\"]}' WHERE name='pdns_version';"
$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_VERSION//[\'\"]}' WHERE name='pdns_version';"

mkdir -p /run/uwsgi
chown uwsgi: /run/uwsgi
Expand Down
6 changes: 3 additions & 3 deletions pdns-recursor/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -euo pipefail
set -eu

# Configure base vars
: "${PDNS_local_port:=53}"
Expand All @@ -18,9 +18,9 @@ elif [ -f /etc/alpine-release ]; then
fi

# 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
chown ${pdns_user}: $config_file
chown "${pdns_user}:" "${config_file}"

exec "$@"
28 changes: 14 additions & 14 deletions pdns/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -euo pipefail
set -eu

# Configure mysql env vars
: "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}"
Expand All @@ -14,23 +14,23 @@ fi

# use first part of node name as database name suffix
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}"
fi


export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname

EXTRA=""

EXTRA=''

# Password Auth
if [ "${PDNS_gmysql_password}" != "" ]; then
if [ "${PDNS_gmysql_password}" ]; then
EXTRA="${EXTRA} -p${PDNS_gmysql_password}"
fi

# Allow socket connections
if [ "${PDNS_gmysql_socket:-}" != "" ]; then
export PDNS_gmysql_host="localhost"
if [ "${PDNS_gmysql_socket:-}" ]; then
export PDNS_gmysql_host='localhost'
EXTRA="${EXTRA} --socket=${PDNS_gmysql_socket}"
fi

Expand Down Expand Up @@ -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
fi

if [ "${PDNS_superslave:-no}" == "yes" ]; then
if [ "${PDNS_superslave:-no}" = 'yes' ]; then
# Configure supermasters if needed
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=''
if [ "${SUPERMASTER_COUNT:-0}" == "0" ]; then
if [ "${SUPERMASTER_COUNT:-0}" -eq 0 ]; then
SUPERMASTER_COUNT=10
fi
i=1; while [ $i -le ${SUPERMASTER_COUNT} ]; do
SUPERMASTER_HOST=$(echo ${SUPERMASTER_HOSTS:-} | awk -v col="$i" '{ print $col }')
SUPERMASTER_IP=$(echo ${SUPERMASTER_IPS} | awk -v col="$i" '{ print $col }')
i=1; while [ $i -le "${SUPERMASTER_COUNT}" ]; do
SUPERMASTER_HOST=$(echo "${SUPERMASTER_HOSTS:-}" | awk -v col="$i" '{ print $col }')
SUPERMASTER_IP=$(echo "${SUPERMASTER_IPS}" | awk -v col="$i" '{ print $col }')
if [ -z "${SUPERMASTER_HOST:-}" ]; then
SUPERMASTER_HOST=$(hostname -f)
fi
Expand All @@ -85,6 +85,6 @@ if [ "${PDNS_superslave:-no}" == "yes" ]; then
fi

# 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 "$@"

0 comments on commit e37b326

Please sign in to comment.