diff mbox series

odhcpd: number UCI defaults script

Message ID 20200920204833.2878-1-foss@volatilesystems.org
State Superseded
Headers show
Series odhcpd: number UCI defaults script | expand

Commit Message

Stijn Segers Sept. 20, 2020, 8:48 p.m. UTC
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@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 mbox series


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 @@ 
+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 ;;
+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