-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·77 lines (66 loc) · 2.05 KB
/
entrypoint.sh
File metadata and controls
executable file
·77 lines (66 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
SQLITE_DBPATH=${SQLITE_DBPATH:-/data/pdns.sqlite}
API_KEY=${API_KEY:-genericapikey}
MASTER=${MASTER:-yes}
SLAVE=${SLAVE:-no}
SLAVE_CYCLE_INTERVAL=${SLAVE_CYCLE_INTERVAL:-60}
DEFAULT_TTL=${DEFAULT_TTL:-3600}
DEFAULT_SOA_NAME=${DEFAULT_SOA_NAME:-$(hostname -f)}
DEFAULT_SOA_MAIL=${DEFAULT_SOA_MAIL}
ALLOW_AXFR_IPS=${ALLOW_AXFR_IPS:-127.0.0.0/8}
ALSO_NOTIFY=${ALSO_NOTIFY}
ALLOW_NOTIFY_FROM=${ALLOW_NOTIFY_FROM}
GSQLITE3_PRAGMA_SYNCHRONOUS=${GSQLITE3_PRAGMA_SYNCHRONOUS:-0}
OPTIONS=()
OPTIONS+="--api=yes "
OPTIONS+="--api-key=${API_KEY} "
OPTIONS+="--webserver=yes "
OPTIONS+="--webserver-address=0.0.0.0 "
OPTIONS+="--launch=gsqlite3 "
OPTIONS+="--gsqlite3-database=${SQLITE_DBPATH} "
OPTIONS+="--gsqlite3-pragma-foreign-keys "
OPTIONS+="--gsqlite3-dnssec "
OPTIONS+="--gsqlite3-pragma-synchronous=${GSQLITE3_PRAGMA_SYNCHRONOUS} "
OPTIONS+="--default-ttl=${DEFAULT_TTL} "
OPTIONS+="--default-soa-name=${DEFAULT_SOA_NAME} "
OPTIONS+="--allow-axfr-ips=${ALLOW_AXFR_IPS} "
OPTIONS+="--slave-cycle-interval=${SLAVE_CYCLE_INTERVAL} "
# Master/Slave management
if [[ ${SLAVE} == "yes" ]]
then
OPTIONS+="--slave=${SLAVE} "
# ALLOW_NOTIFY_FROM must be set
if [[ -z ${ALLOW_NOTIFY_FROM} ]]; then
echo "ALLOW_NOTIFY_FROM is not set, please configure this when to turn slave mode on."
exit 1
fi
OPTIONS+="--allow-notify-from=${ALLOW_NOTIFY_FROM} "
elif [[ ${MASTER} == "yes" ]]
then
OPTIONS+="--master=${MASTER} "
else
echo "Error, PowerDNS must be configured in either master or slave mode"
exit 1
fi
# also-notify
if [[ -n ${ALSO_NOTIFY} ]]
then
OPTIONS+="--also-notify=$ALSO_NOTIFY "
fi
# default-soa-email
if [[ -n ${DEFAULT_SOA_MAIL} ]]; then
OPTIONS+="--default-soa-mail=${DEFAULT_SOA_MAIL} "
fi
# Init the sqlite db if it does not exist
if [[ ! -e ${SQLITE_DBPATH} ]]
then
cat /pdns/init.sql | sqlite3 ${SQLITE_DBPATH}
else
echo "Database exist and some tables were found."
echo "Assuming this is not the first launch"
fi
# Set correct permissions
chown -Rv pdns:pdns /data
chown -Rv pdns:pdns ${SQLITE_DBPATH}
# Start PowerDNS
pdns_server ${OPTIONS}