Uci-defaults script for dhcp being ignored

i tried to set "relay" mode on dhcp.lan but it doesnt apply, even if i do delete and recreate dhcp.lan, it always set to server unless i did it via web ui/luci, why ?

Share your script for review.

here's my recent code (still not working as expected)

#!/bin/sh

set -ex; exec >/root/network.log 2>&1;

# Interfaces

# LAN
uci set network.lan.ipaddr='192.168.96.1';
uci set network.lan.ip6assign='64';
uci commit network.lan;

[ "$(uci -q get dhcp.lan)" = "dhcp" ] && {
    uci del dhcp.lan;
    uci commit dhcp;
    sync;
};
uci set dhcp.lan=dhcp;
uci set dhcp.lan.interface='lan';
uci set dhcp.lan.start='100';
uci set dhcp.lan.limit='150';
uci set dhcp.lan.leasetime='12h';
uci set dhcp.lan.ra='relay';
uci set dhcp.lan.dhcpv6='relay';
uci set dhcp.lan.ndp='relay';
uci set dhcp.lan.dhcpv4='server';
uci commit dhcp.lan;

...(other code like setting wan, etc)

and here's the log

~# cat network.log
+ uci set 'network.lan.ipaddr=192.168.96.1'
+ uci set 'network.lan.ip6assign=64'
+ uci commit network.lan
+ uci -q get dhcp.lan
+ '[' dhcp '=' dhcp ]
+ uci del dhcp.lan
+ uci commit dhcp
+ sync
+ uci set 'dhcp.lan=dhcp'
+ uci set 'dhcp.lan.interface=lan'
+ uci set 'dhcp.lan.start=100'
+ uci set 'dhcp.lan.limit=150'
+ uci set 'dhcp.lan.leasetime=12h'
+ uci set 'dhcp.lan.ra=relay'
+ uci set 'dhcp.lan.dhcpv6=relay'
+ uci set 'dhcp.lan.ndp=relay'
+ uci set 'dhcp.lan.dhcpv4=server'
+ uci commit dhcp.lan
+ uci set 'network.wan=interface'
+

after viewing image contents it turns out that i just need to set higher sequence number to avoid conflict with odhcpd

Uci-defaults doesn’t use sequence numbers.

The script files are deployed in /buildroot/files when you build the image.

but that solves the problem, ie: i writing 02-network with content

uci del dhcp.lan.ra

doesn't make sense since there's also 15-odhcpd which has

set dhcp.lan.ra=...

15-odhcpd is from package, not by me, by mean sequence number is the filename number prefix

We do have a uci-defaults guide

https://openwrt.org/docs/guide-developer/uci-defaults

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.