Tidy up scripts

This commit is contained in:
Peter Schiffer 2023-12-19 23:12:51 +01:00
parent 15d3225d61
commit e37b326748
No known key found for this signature in database
GPG key ID: F2A18AC34A008397
7 changed files with 33 additions and 33 deletions

View file

@ -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

View file

@ -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:

View file

@ -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

View file

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

View file

@ -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}"
@ -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

View file

@ -1,6 +1,6 @@
#!/bin/sh
set -euo pipefail
set -eu
# Configure base vars
: "${PDNS_local_port:=53}"
@ -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 "$@"

View file

@ -1,6 +1,6 @@
#!/bin/sh
set -euo pipefail
set -eu
# Configure mysql env vars
: "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}"
@ -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
@ -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
@ -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 "$@"