Skip to content

Commit f67db72

Browse files
committed
unbound-uci-ext: add new package
unbound-uci-ext adds UCI options for unbound directives that the unbound package leaves out of UCI. It writes a marked region in /etc/unbound/unbound_srv.conf and /etc/unbound/unbound_ext.conf, the two files that unbound ships for local additions, and it keeps everything outside that region. - /etc/config/unbound_srv renders interface, outgoing-interface, ip-transparent and raw lines inside the server: clause. - /etc/config/unbound_ext renders raw lines for clauses such as forward-zone:, stub-zone: and view:. - A procd init script with a reload trigger on both configs. unbound restarts only when a file changed. Stopping the service removes the marked regions. - Both configs ship disabled, so an install changes nothing. - test.sh renders both configs into temporary files, and checks the rendered lines, the text outside the region and the clean-up. Release notes: https://github.com/openwrt-iac/unbound-uci-ext/releases/tag/v0.2.2 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Guy Godfroy <guy.godfroy@gugod.fr>
1 parent 8b43768 commit f67db72

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

‎net/unbound-uci-ext/Makefile‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=unbound-uci-ext
4+
PKG_VERSION:=0.2.2
5+
PKG_RELEASE:=1
6+
7+
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
8+
PKG_SOURCE_URL:=https://codeload.github.com/openwrt-iac/unbound-uci-ext/tar.gz/v$(PKG_VERSION)?
9+
PKG_HASH:=741a0362817cd8874f8d53e745fde664f92c64e1b5bc57a48cd27b2efee06d26
10+
11+
PKG_MAINTAINER:=Guy Godfroy <guy.godfroy@gugod.fr>
12+
PKG_LICENSE:=MIT
13+
PKG_LICENSE_FILES:=LICENSE
14+
15+
include $(INCLUDE_DIR)/package.mk
16+
17+
define Package/unbound-uci-ext
18+
SECTION:=net
19+
CATEGORY:=Network
20+
SUBMENU:=IP Addresses and Names
21+
TITLE:=UCI options for unbound's extended config files
22+
URL:=https://github.com/openwrt-iac/unbound-uci-ext
23+
PKGARCH:=all
24+
DEPENDS:=+unbound-daemon
25+
endef
26+
27+
define Package/unbound-uci-ext/description
28+
Adds UCI options for unbound directives that the unbound package
29+
leaves out of UCI. /etc/config/unbound_srv renders into a marked
30+
region of /etc/unbound/unbound_srv.conf, inside the server: clause:
31+
interface, outgoing-interface, ip-transparent and raw server lines.
32+
/etc/config/unbound_ext renders raw lines into a marked region of
33+
/etc/unbound/unbound_ext.conf, for clauses such as forward-zone:,
34+
stub-zone: and view:. Content outside the marked regions stays as
35+
it is, and unbound restarts only when a file changes.
36+
endef
37+
38+
define Package/unbound-uci-ext/conffiles
39+
/etc/config/unbound_ext
40+
/etc/config/unbound_srv
41+
endef
42+
43+
Build/Compile=
44+
45+
define Package/unbound-uci-ext/install
46+
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d $(1)/usr/lib/unbound-uci-ext
47+
$(INSTALL_CONF) $(PKG_BUILD_DIR)/files/etc/config/unbound_ext \
48+
$(PKG_BUILD_DIR)/files/etc/config/unbound_srv $(1)/etc/config/
49+
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/init.d/unbound-uci-ext $(1)/etc/init.d/
50+
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/usr/lib/unbound-uci-ext/generator.sh \
51+
$(1)/usr/lib/unbound-uci-ext/
52+
endef
53+
54+
$(eval $(call BuildPackage,unbound-uci-ext))

‎net/unbound-uci-ext/test.sh‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
# shellcheck shell=busybox
4+
5+
set -e
6+
7+
export SRV_CONF=/tmp/unbound_srv.conf EXT_CONF=/tmp/unbound_ext.conf
8+
gen=/usr/lib/unbound-uci-ext/generator.sh
9+
10+
echo 'local-zone: "kept." static' > "$SRV_CONF"
11+
uci set unbound_srv.main.enabled=1
12+
uci add_list unbound_srv.main.interface_bind='127.0.0.1@5353'
13+
uci set unbound_ext.main.enabled=1
14+
uci add_list unbound_ext.main.ext_line='forward-zone:'
15+
uci add_list unbound_ext.main.ext_line=' name: "example.org"'
16+
uci commit
17+
18+
"$gen" apply
19+
grep -Fx 'local-zone: "kept." static' "$SRV_CONF"
20+
grep -Fx 'interface: 127.0.0.1@5353' "$SRV_CONF"
21+
grep -Fx ' name: "example.org"' "$EXT_CONF"
22+
23+
"$gen" clear
24+
grep -Fx 'local-zone: "kept." static' "$SRV_CONF"
25+
! grep -F 'interface:' "$SRV_CONF" || exit 1
26+
! grep -F 'name: "example.org"' "$EXT_CONF" || exit 1

0 commit comments

Comments
 (0)