postinst is in pdns-server 3.3-2.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | #!/bin/sh
#
# postinst script for pdns-server
set -e
# Load debconf
. /usr/share/debconf/confmodule
if [ -n "$PDNSDEBUG" ]; then
echo "now debugging $0 $@"
set -x
fi
PKGNAME="pdns-server"
PDNSCONF=/etc/powerdns/pdns.conf
PDNSDEFAULT=/etc/default/pdns
if [ -e $PDNSCONF ]; then
PDNSDIR=`cat $PDNSCONF | grep include | awk -F '=' '{print $2}'`
fi
if [ -z "$PDNSDIR" ]; then
PDNSDIR=/etc/powerdns/pdns.d
fi
PDNSLOCAL=$PDNSDIR/pdns.local.conf
# Temporary files
PDNSCONFTEMP=`mktemp`
PDNSLOCALTEMP=`mktemp`
PDNSDEFAULTTEMP=`mktemp`
# rename ucf-conffile. This was mostly stolen from cacti.postinst after
# a short discussion on debian-mentors, see
# http://lists.debian.org/debian-mentors/2013/07/msg00027.html
# and the following thread. Thanks to Paul Gevers
renameconffile() {
oldname="$1"
newname="$2"
sourcefile="$3"
if [ -f $oldname ] ; then
if [ ! -e $newname ] ; then
mv $oldname $newname
# else: Don't do anything, leave old file in place
fi
ucf --purge $oldname
ucfr --purge $PKGNAME $oldname
elif [ ! -e $newname ] ; then
# The file was removed, we should respect that. Unfortunately, we don't
# have a proper way to tell ucf that for the new location, so we need
# to hack it a bit.
# We only need to do this if the target does not already exist. If the
# target already exists, we can later call ucf straight as there
# is already a version of the file available, althought never
# provided by this package, but we can just propose the new file anyway.
ucf --debconf-ok $sourcefile $newname
ucfr $PKGNAME $newname
rm -f $newname
fi
}
case "$1" in
configure)
if [ -z "`getent group pdns`" ]; then
addgroup --quiet --system pdns
fi
if [ -z "`getent passwd pdns`" ]; then
echo -n "Creating user and group pdns..."
adduser --quiet --system --home /var/spool/powerdns --shell /bin/false --ingroup pdns --disabled-password --disabled-login --gecos "PowerDNS" pdns
echo "done"
fi
# Fill the temporary files with config items.
cat /usr/share/pdns-server/pdns.conf > $PDNSCONFTEMP
cat /usr/share/pdns-server/pdns.local.conf > $PDNSLOCALTEMP
cat /usr/share/pdns-server/pdns > $PDNSDEFAULTTEMP
# Do we listen on a specified address
db_get pdns-server/localaddress || true
if [ ! -z "$RET" ]; then
sed -i -e "s|^\(#\)\?\(# \)\?local-address=.*$|local-address=$RET|" $PDNSCONFTEMP
fi
# Allow recursion subnets ?
db_get pdns-server/allowrecursion || true
if [ ! -z "$RET" ]; then
sed -i -e "s|^\(#\)\?\(# \)\?allow-recursion=.*$|allow-recursion=$RET|" $PDNSCONFTEMP
fi
# this can be removed once we do not have to update from
# wheezy (pdns 3.1) any more. Note: there was never pdns 3.2 in Debian
if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.3; then
renameconffile $PDNSDIR/pdns.local $PDNSDIR/pdns.local.conf $PDNSLOCALTEMP
renameconffile $PDNSDIR/pdns.simplebind $PDNSDIR/pdns.simplebind.conf /usr/share/pdns-server/pdns.simplebind.conf
fi
# register configuration files with ucf
ucfr $PKGNAME $PDNSCONF
ucfr $PKGNAME $PDNSDEFAULT
ucfr $PKGNAME $PDNSLOCAL
ucfr $PKGNAME $PDNSDIR/pdns.simplebind.conf
# Install the new configuration files if the user wants it.
ucf --debconf-ok $PDNSCONFTEMP $PDNSCONF
ucf --debconf-ok $PDNSDEFAULTTEMP $PDNSDEFAULT
ucf --debconf-ok $PDNSLOCALTEMP $PDNSLOCAL
ucf --debconf-ok /usr/share/pdns-server/pdns.simplebind.conf $PDNSDIR/pdns.simplebind.conf
# Stop the debconf stuff
db_stop || true
# Clean up temporary files.
rm -f $PDNSCONFTEMP $PDNSLOCALTEMP $PDNSDEFAULTTEMP
# There could be passwords in these files. PowerDNS first reads the
# configuration files and then drop root privileges.
if [ -z "$2" ]; then
[ -e $PDNSCONF ] && chmod 0600 $PDNSCONF
[ -e $PDNSLOCAL ] && chmod 0600 $PDNSLOCAL
[ -d $PDNSDIR ] && chmod 0755 $PDNSDIR
[ -e $PDNSDEFAULT ] && chmod 0644 $PDNSDEFAULT
fi
# If we still have the default config, make sure bindbackend.conf exists
PDNSBIND="/etc/powerdns/pdns.d/pdns.simplebind.conf"
PDNSBINDBACKENDCONF="/etc/powerdns/bindbackend.conf"
if [ -e "$PDNSBIND" ]; then
if grep -q "^bind-config=$PDNSBINDBACKENDCONF$" $PDNSBIND; then
touch $PDNSBINDBACKENDCONF
fi
fi
;;
triggered)
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d pdns restart || exit $?
else
/etc/init.d/pdns restart || exit $?
fi
# Stop the debconf stuff
db_stop || true
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# Recover from incorrect init.d script headers in version 2.9.22-1 and earlier
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le "2.9.22-1" \
&& [ -f /etc/rc0.d/K[0-9][0-9]pdns ] \
&& ! [ -f /etc/rc1.d/K[0-9][0-9]pdns ]; then
update-rc.d -f pdns remove
fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_installinit
if [ -x "/etc/init.d/pdns" ] || [ -e "/etc/init/pdns.conf" ]; then
if [ ! -e "/etc/init/pdns.conf" ]; then
update-rc.d pdns defaults >/dev/null
fi
invoke-rc.d pdns start || exit $?
fi
# End automatically added section
exit 0
|