dnsmngr: add unbound as selectable backend

* add dependencies for different backends in dhcpmngr and
  dnsmngr
* use CFLAG to indicate to data model code which backend is being
  used currently
* add uci-defaults script to set leasetrigger if unbound is dns
  backend
This commit is contained in:
Mohd Husaam Mehdi 2024-08-16 18:05:58 +05:30 committed by Rahul Thakur
parent 5068f2ae2d
commit 47fe2abfe0
4 changed files with 52 additions and 4 deletions

View file

@ -28,7 +28,9 @@ define Package/dhcpmngr
SECTION:=net
CATEGORY:=Network
TITLE:=Package to add Device.DHCPv4 and v6 data model support.
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +dnsmasq
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +odhcpd
DEPENDS+=+DNSMNGR_DNS_SD:umdns
DEPENDS+=+DNSMNGR_BACKEND_DNSMASQ:dnsmasq
endef
define Package/dhcpmngr/description
@ -44,6 +46,10 @@ endif
define Package/dhcpmngr/install
$(INSTALL_DIR) $(1)/etc/udhcpc.user.d
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_lease_start_time.user $(1)/etc/udhcpc.user.d/udhcpc_lease_start_time.user
ifeq ($(CONFIG_DNSMNGR_BACKEND_UNBOUND),y)
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DATA) ./files/etc/uci-defaults/unbound.odhcpd.uci_default $(1)/etc/uci-defaults/16-set-unbound-as-odhcpd-leasetrigger
endif
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/src/libdhcpmngr.so $(1) $(PKG_NAME)
endef

View file

@ -0,0 +1,18 @@
#!/bin/sh
# update odhcpd uci to use unbound's script as leasetrigger
uci -q get dhcp.odhcpd >/dev/null 2>&1 && {
maindhcp="$(uci -q get dhcp.odhcpd.maindhcp)"
# if odhcpd is the main dhcp
[ "$maindhcp" = "1" ] || [ "$maindhcp" = "true" ] || [ "$maindhcp" = "on" ] && {
# if unbound daemon and unbound script file is present
[ -e /usr/lib/unbound/odhcpd.sh ] && [ -e /usr/sbin/unbound ] && {
# then set unbound script as leasetrigger in dhcp UCI
uci -q set dhcp.odhcpd.leasetrigger='/usr/lib/unbound/odhcpd.sh'
uci commit dhcp
}
}
}
exit 0

View file

@ -8,5 +8,23 @@ config DNSMNGR_DNS_SD
help
Set this option to include support for TR-181 DNS.SD. object.
choice
prompt "Select backend for DNS management"
default DNSMNGR_BACKEND_DNSMASQ
depends on PACKAGE_dnsmngr
help
Select which backend daemon to use for DNS
config DNSMNGR_BACKEND_DNSMASQ
bool "Use dnsmasq for dns and dhcp"
help
Enable this option to use dnsmasq + odhcpd for dns and dhcp.
config DNSMNGR_BACKEND_UNBOUND
bool "Use unbound with odhcpd-full for dns and dhcp"
help
Enable this option to use unbound + odhcpd for dns and dhcp.
endchoice
endmenu
endif

View file

@ -27,13 +27,15 @@ MAKE_PATH:=src
define Package/dnsmngr
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +dnsmasq
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +odhcpd
DEPENDS+=+DNSMNGR_DNS_SD:umdns
TITLE:=Package to add Device.DNS. datamodel support
DEPENDS+=+DNSMNGR_BACKEND_DNSMASQ:dnsmasq
DEPENDS+=+DNSMNGR_BACKEND_UNBOUND:unbound-daemon +DNSMNGR_BACKEND_UNBOUND:unbound-control
TITLE:=Package to configure DNS backend and TR-181 support
endef
define Package/dnsmngr/description
Package to add Device.DNS. datamodel support.
Package to configure DNS backend and TR-181 support.
endef
define Package/$(PKG_NAME)/config
@ -56,6 +58,10 @@ define Build/Prepare
endef
endif
ifeq ($(CONFIG_DNSMNGR_BACKEND_DNSMASQ),y)
TARGET_CFLAGS += -DDNSMASQ_BACKEND
endif
define Package/dnsmngr/install
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/src/libdnsmngr.so $(1) $(PKG_NAME)
$(BBFDM_INSTALL_SCRIPT) -d $(PKG_BUILD_DIR)/scripts/nslookup $(1)