#!/bin/sh -u

. ddns-sh-functions

echo -n '' > $bind_root_dir/$ddns_domain_file
/sbin/service bind restart >&2

### dynamic variables
resolvconfzone_file="$bind_root_dir/etc/resolvconf-zones.conf"

#clear resolvconf zones information
if [ -f "$resolvconfzone_file" ];then
    echo "Cleaning up resolvconf zones..." >&2
    >"$resolvconfzone_file"
fi

#remove previous zone definitions
rm -f -- "$bind_root_dir/$ddns_domain_file"
rm -f -- "$bind_root_dir/zone/$ddns_domain_dir"/*

ddns_create_domain "$(ddns_system_zone)" "master" "1"

/usr/sbin/dhcp-reset-static

#update resolvconf zones information
if [ -f "$resolvconfzone_file" ];then
    echo "Update resolvconf zones..." >&2
    resolvconf -u
fi

/sbin/service bind condreload >&2
