netmode: fallback to checking usr_data if /opconf/opconf.json is not available

This commit is contained in:
Sukru Senli 2025-12-05 17:19:36 +01:00
parent 59e7ece054
commit a0c1801511

View file

@ -5,15 +5,18 @@ if [ "$enabled" != "1" ]; then
exit 0
fi
opconf_file="/opconf/opconf.json"
[ -f $opconf_file ] || opconf_file="/usr_data/opconf/opconf.json"
# Check if netmode getting provisioned from opconf, in case of opconf
# provisioning, mode setting not required
mode="$(jsonfilter -i /opconf/opconf.json -e @.netmode.mode 2>/dev/null)"
mode="$(jsonfilter -i $opconf_file -e @.netmode.mode 2>/dev/null)"
if [ -n "${mode}" ]; then
exit 0
fi
# Check if opconf has wan provisioning enabled, if yes, get the proto/mode from opconf
proto="$(jsonfilter -i /usr_data/opconf/opconf.json -e '@.network.wan[@.name="wan"].proto' 2>/dev/null)"
proto="$(jsonfilter -i $opconf_file -e '@.network.wan[@.name="wan"].proto' 2>/dev/null)"
if [ -n "${proto}" ]; then
mode="routed-${proto}"
uci -q set netmode.global.mode="${mode}"