| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
if [ "$1" = configure ]; then |
| 6 |
# lets give them a bind user/group in all cases. |
| 7 |
getent group bind >/dev/null 2>&1 || addgroup --system bind |
| 8 |
getent passwd bind >/dev/null 2>&1 || |
| 9 |
adduser --system --home /var/cache/bind --no-create-home \ |
| 10 |
--disabled-password --ingroup bind bind |
| 11 |
|
| 12 |
# create data directory on fresh install |
| 13 |
if [ -z "$2" ]; then |
| 14 |
mkdir -p /var/lib/bind |
| 15 |
chown root:bind /var/lib/bind |
| 16 |
chmod 775 /var/lib/bind |
| 17 |
fi |
| 18 |
|
| 19 |
if [ ! -s /etc/bind/rndc.key ] && [ ! -s /etc/bind/rndc.conf ]; then |
| 20 |
rndc-confgen -a |
| 21 |
fi |
| 22 |
|
| 23 |
uid=$(ls -ln /etc/bind/rndc.key | awk '{print $3}') |
| 24 |
if [ "$uid" = "0" ]; then |
| 25 |
chown bind /etc/bind/rndc.key |
| 26 |
chgrp bind /etc/bind |
| 27 |
chmod g+s /etc/bind |
| 28 |
chgrp bind /etc/bind/rndc.key /var/cache/bind |
| 29 |
chgrp bind /etc/bind/named.conf* || true |
| 30 |
chmod g+r /etc/bind/rndc.key /etc/bind/named.conf* || true |
| 31 |
chmod g+rwx /var/cache/bind |
| 32 |
fi |
| 33 |
|
| 34 |
if [ -e /etc/bind/named.conf.default-zones.dpkg-dist ]; then |
| 35 |
rm -f /etc/bind/named.conf.default-zones.dpkg-dist |
| 36 |
fi |
| 37 |
|
| 38 |
# Configuration file sanity check. This should avoid the upgrade process to |
| 39 |
# stop a running service when starting it after the upgrade would fail |
| 40 |
named-checkconf /etc/bind/named.conf |
| 41 |
fi |
| 42 |
|
| 43 |
#DEBHELPER# |
| 44 |
|
| 45 |
exit 0 |