2017-12-11 14:18:10 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-12-19 23:12:51 +01:00
|
|
|
set -eu
|
2017-12-11 14:18:10 +01:00
|
|
|
|
2024-05-06 17:13:13 +02:00
|
|
|
#### Function definitions
|
2024-06-04 00:28:32 +02:00
|
|
|
|
|
|
|
deriveConfigValuesFromEnvrionement() {
|
2024-05-06 17:13:13 +02:00
|
|
|
# Configure base vars
|
|
|
|
: "${PDNS_local_port:=53}"
|
|
|
|
: "${PDNS_local_address:=0.0.0.0}"
|
|
|
|
: "${PDNS_allow_from:=0.0.0.0/0}"
|
2024-06-04 00:28:32 +02:00
|
|
|
|
2024-05-06 17:13:13 +02:00
|
|
|
export PDNS_local_port PDNS_local_address PDNS_allow_from
|
|
|
|
}
|
2017-12-11 14:18:10 +01:00
|
|
|
|
2024-06-04 00:28:32 +02:00
|
|
|
### End of function definitions
|
2018-11-06 22:51:45 +01:00
|
|
|
|
|
|
|
if [ -f /etc/fedora-release ]; then
|
|
|
|
config_file=/etc/pdns-recursor/recursor.conf
|
|
|
|
pdns_user=pdns-recursor
|
|
|
|
elif [ -f /etc/alpine-release ]; then
|
|
|
|
config_file=/etc/pdns/recursor.conf
|
|
|
|
pdns_user=recursor
|
|
|
|
fi
|
2017-12-11 14:18:10 +01:00
|
|
|
|
2024-06-04 00:28:32 +02:00
|
|
|
if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'false' ]; then
|
2024-05-06 17:13:13 +02:00
|
|
|
deriveConfigValuesFromEnvrionement
|
2024-06-04 00:28:32 +02:00
|
|
|
echo "Generating config file from environment"
|
2024-05-06 17:13:13 +02:00
|
|
|
subvars --prefix 'PDNS_' < '/recursor.conf.tpl' > "${config_file}"
|
|
|
|
chown "${pdns_user}:" "${config_file}"
|
|
|
|
else
|
2024-06-04 00:28:32 +02:00
|
|
|
echo "Using existing config file ${config_file}"
|
|
|
|
fi
|
2017-12-27 18:58:53 +01:00
|
|
|
|
2018-11-22 19:45:43 +01:00
|
|
|
exec "$@"
|