#
# thomas@linuxmuster.net
# 28.02.2015
# GPL v3
#

echo "### 06_bind postpatch"

# fix permissions
chown root:bind /etc/bind
chmod 775 /etc/bind
chown root:bind /etc/bind/db.10
chown root:bind /etc/bind/db.linuxmuster
chown -f root:bind /etc/bind/db.extern
chmod 664 /etc/bind/db.10
chmod 664 /etc/bind/db.linuxmuster
chmod -f 664 /etc/bind/db.extern

# delete journaling files
ls /etc/bind/*.jnl &> /dev/null && rm /etc/bind/*.jnl

# create rndc-keyfile if necessary
if [ ! -e /etc/bind/rndc.key ]; then
  echo "Creating /etc/bind/rndc.key ..."
  rndc-confgen -a -u bind
else
  chown bind /etc/bind/rndc.key
fi

# start the service
service bind9 start
