2
# postinst script for pdns-server
4
# see: dh_installdeb(1)
8
. /usr/share/debconf/confmodule
10
# summary of how this script can be called:
11
# * <postinst> `configure' <most-recently-configured-version>
12
# * <old-postinst> `abort-upgrade' <new version>
13
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
15
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
16
# <failed-install-package> <version> `removing'
17
# <conflicting-package> <version>
18
# for details, see http://www.debian.org/doc/debian-policy/ or
19
# the debian-policy package
22
PDNSCONF=/etc/powerdns/pdns.conf
23
PDNSDEFAULT=/etc/default/pdns
24
if [ -e $PDNSCONF ]; then
25
PDNSDIR=`cat $PDNSCONF | grep include | awk -F '=' '{print $2}'`
27
if [ -z $PDNSDIR ]; then
28
PDNSDIR=/etc/powerdns/pdns.d
30
PDNSLOCAL=$PDNSDIR/pdns.local
34
PDNSLOCALTEMP=`mktemp`
35
PDNSDEFAULTTEMP=`mktemp`
38
if [ -e $PDNSCONF ]; then
39
for i in geo ldap gmysql gpgsql pipe gsqlite; do
40
CONF=`(cat $PDNSCONF | grep -- $i-) || /bin/true`
41
if [ ! -z "$CONF" ]; then
43
echo $j >> $PDNSLOCALTEMP
52
# Fill the temporary files with config items.
53
cat /usr/share/pdns-server/pdns.conf > $PDNSCONFTEMP
54
cat /usr/share/pdns-server/pdns.local > $PDNSLOCALTEMP
55
cat /usr/share/pdns-server/pdns > $PDNSDEFAULTTEMP
60
# Do we listen on a specified address
61
db_get pdns-server/localaddress || true
62
if [ ! -z "$RET" ]; then
63
sed -i -e "s|^\(#\)\?\(# \)\?local-address=.*$|local-address=$RET|" $PDNSCONFTEMP
66
# Allow recursion subnets ?
67
db_get pdns-server/allowrecursion || true
68
if [ ! -z "$RET" ]; then
69
sed -i -e "s|^\(#\)\?\(# \)\?allow-recursion=.*$|allow-recursion=$RET|" $PDNSCONFTEMP
73
db_get pdns-server/autostart || true
74
[ -z "$RET" ] && RET=false
75
if [ "$RET" = "true" ]; then
76
sed -i -e "s/^START=.*$/START=yes/" $PDNSDEFAULTTEMP
79
# Stop the debconf stuff
82
# Install the new configuration files if the user wants it.
83
ucf $PDNSCONFTEMP $PDNSCONF
84
ucf $PDNSDEFAULTTEMP $PDNSDEFAULT
85
ucf $PDNSLOCALTEMP $PDNSLOCAL
87
# Clean up temporary files.
88
rm -f $PDNSCONFTEMP $PDNSDEFAULTTEMP $PDNSLOCALTEMP
90
# There could be passwords in these files. PowerDNS first reads the
91
# configuration files and then drop root privileges.
92
chmod 0600 $PDNSCONF $PDNSLOCAL
96
abort-upgrade|abort-remove|abort-deconfigure)
100
echo "postinst called with unknown argument \`$1'" >&2
105
if [ -x "/etc/init.d/pdns" ]; then
106
update-rc.d pdns defaults 20 85 >/dev/null || exit 0
107
if [ -x /usr/sbin/invoke-rc.d ]; then
108
invoke-rc.d pdns start || exit 0
110
/etc/init.d/pdns start || exit 0
114
# dh_installdeb will replace this with shell code automatically
115
# generated by other debhelper scripts.