lib_dir=/var/lib/bind
config_file=$config_dir/named.conf
-config_local_file=$dyn_dir/named.conf.local
reload_service() {
rndc -q reload
chmod 0640 /etc/bind/rndc.key
fi
- touch $config_local_file
-
if [ -z "$(ip -6 -o route show default)" ]; then
args="-4"
else
procd_open_instance
procd_set_param command /usr/sbin/named -u bind -f $args -c $config_file
- procd_set_param file $config_file $config_local_file $config_dir/db.*
+ procd_set_param file $config_file $config_dir/db.*
procd_set_param respawn
procd_close_instance
}
UPSTREAM_NAME:=dhcp
PKG_REALVERSION:=4.4.3-P1
PKG_VERSION:=4.4.3_p1
-PKG_RELEASE:=10
+PKG_RELEASE:=11
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE
define Package/isc-dhcp-dyndns
$(call Package/isc-dhcp/Default)
TITLE+= server dynamic DNS dependencies (meta)
- DEPENDS+=@(PACKAGE_isc-dhcp-server-ipv4||PACKAGE_isc-dhcp-server-ipv6) +bind-server +bind-client
+ DEPENDS+=@(PACKAGE_isc-dhcp-server-ipv4||PACKAGE_isc-dhcp-server-ipv6) \
+ +bind-server \
+ +bind-rndc \
+ +bind-client
endef
define Package/isc-dhcp-dyndns/description
lease_file=/tmp/dhcpd.leases
config_file=/tmp/run/dhcpd.conf
-dyndir=/tmp/bind
-conf_local_file=$dyndir/named.conf.local
+dyndir=/var/run/dhcp
session_key_name=local-ddns
session_key_file=/var/run/named/session.key
echo "$result"
}
+write_empty_zone() {
+ local zpath
+ zpath="$1"
+
+ cat > "$zpath" <<\EOF
+;
+; BIND empty zone created by isc-dhcp-server
+;
+$TTL 604800
+@ IN SOA localhost. root.localhost. (
+ 1 ; Serial
+ 604800 ; Refresh
+ 86400 ; Retry
+ 2419200 ; Expire
+ 604800 ) ; Negative Cache TTL
+;
+@ IN NS localhost.
+EOF
+}
+
create_empty_zone() {
- local zone="$1"
+ local zone error zpath
+ zone="$1"
+ zpath="$dyndir/db.$zone"
+
+ if [ ! -d "$dyndir" ]; then
+ mkdir -p "$dyndir" || return 1
+ chown bind:bind "$dyndir" || return 1
+ fi
- if [ ! -f $dyndir/db."$zone" ]; then
- cp -p /etc/bind/db.empty $dyndir/db."$zone"
- chmod g+w $dyndir/db."$zone"
- chgrp bind $dyndir/db."$zone"
+ write_empty_zone "$zpath"
+ chown bind:bind "$zpath" || return 1
+ chmod 0664 "$zpath" || return 1
+
+ if ! error=$(rndc addzone $zone "{
+ type primary;
+ file \"$zpath\";
+ update-policy {
+ grant $session_key_name zonesub any;
+ };
+ };" 2>&1); then
+ case "$error" in
+ *"already exists"*)
+ ;;
+ *)
+ logger -p info -t isc-dhcp "Failed to add zone $zone: $error"
+ return 1
+ ;;
+ esac
fi
}
[ $? -ne 0 ] && return 1
if [ $dynamicdns -eq 1 ]; then
+ rndc freeze
+
create_empty_zone "$domain"
local mynet
create_empty_zone "$mynet.in-addr.arpa"
done
- local need_reload=
-
- cp -p $conf_local_file ${conf_local_file}_
-
- cat <<EOF > $conf_local_file
-zone "$domain" {
- type master;
- file "$dyndir/db.$domain";
- update-policy {
- grant $session_key_name zonesub any;
- };
-};
-
-EOF
-
- for mynet in $rfc1918_nets; do
- mynet="$(rev_str "$mynet" ".")"
- cat <<EOF >> $conf_local_file
-zone "$mynet.in-addr.arpa" {
- type master;
- file "$dyndir/db.$mynet.in-addr.arpa";
- update-policy {
- grant $session_key_name zonesub any;
- };
-};
-
-EOF
- done
-
- cmp -s $conf_local_file ${conf_local_file}_ || need_reload=1
- rm -f ${conf_local_file}_
-
- [ -n "$need_reload" ] && /etc/init.d/named reload
- sleep 1
+ rndc thaw
cat <<EOF
ddns-domainname "$domain.";