[PATCH] odhcpd: number UCI defaults script

Stijn Segers foss at volatilesystems.org
Sun Sep 20 16:48:33 EDT 2020


UCI defaults scripts are supposed to be numbered, but odhcpd's lacked numbering, which
turned out to mess up my custom scripts numbered 9[0-9]_*. The idea is to have high number
scripts executed last. Jow confirmed numbering is the default case, not the exception (thanks).

Signed-off-by: Stijn Segers <foss at volatilesystems.org>
---
 .../services/odhcpd/files/15_odhcpd.defaults  | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 package/network/services/odhcpd/files/15_odhcpd.defaults

diff --git a/package/network/services/odhcpd/files/15_odhcpd.defaults b/package/network/services/odhcpd/files/15_odhcpd.defaults
new file mode 100644
index 0000000000..5a1706f785
--- /dev/null
+++ b/package/network/services/odhcpd/files/15_odhcpd.defaults
@@ -0,0 +1,32 @@
+#!/bin/sh
+uci -q get dhcp.odhcpd && exit 0
+touch /etc/config/dhcp
+
+. /usr/share/libubox/jshn.sh
+
+json_load "$(cat /etc/board.json)"
+json_select network
+json_select lan
+json_get_vars protocol
+json_select ..
+json_select ..
+
+case "$protocol" in
+# only enable server mode on statically addressed lan ports
+"static") [ -e /proc/sys/net/ipv6 ] && MODE=server || MODE=disabled ;;
+*) MODE=disabled ;;
+esac
+
+uci batch <<EOF
+set dhcp.odhcpd=odhcpd
+set dhcp.odhcpd.maindhcp=0
+set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
+set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
+set dhcp.odhcpd.loglevel=4
+set dhcp.lan.dhcpv6=$MODE
+set dhcp.lan.ra=$MODE
+set dhcp.lan.ra_slaac=1
+add_list dhcp.lan.ra_flags=managed-config
+add_list dhcp.lan.ra_flags=other-config
+commit dhcp
+EOF
-- 
2.20.1




More information about the openwrt-devel mailing list