Reduce traffic for configsync and handle more priming quirks

This commit is contained in:
Alex D. 2024-02-16 09:52:39 +00:00
parent 5402e7ce24
commit 4963afa8d6
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 16 additions and 1 deletions

View File

@ -9,8 +9,10 @@ uci delete 'firewall.lan.network'
uci add_list 'firewall.lan.network'=iface_lan uci add_list 'firewall.lan.network'=iface_lan
uci rename 'network.lan'=iface_lan uci rename 'network.lan'=iface_lan
while uci -q delete 'network.@interfaces[1]'; do :; done # Delete any non-standard interfaces
uci rename 'network.@device[0]'=br_lan uci rename 'network.@device[0]'=br_lan
while uci -q delete 'network.@device[1]'; do :; done # Delete any non-standard devices
uci rename 'wireless.radio0'=radio24 uci rename 'wireless.radio0'=radio24
uci rename 'wireless.default_radio0'=iface_radio24 uci rename 'wireless.default_radio0'=iface_radio24
@ -18,4 +20,14 @@ uci rename 'wireless.default_radio0'=iface_radio24
uci rename 'wireless.radio1'=radio5 uci rename 'wireless.radio1'=radio5
uci rename 'wireless.default_radio1'=iface_radio5 uci rename 'wireless.default_radio1'=iface_radio5
uci get network.@switch[0] && uci rename network.@switch[0]=switch0
while uci -q delete 'dhcp.@dhcp[0]'; do :; done # Delete any DHCP configuration on initial setup while uci -q delete 'dhcp.@dhcp[0]'; do :; done # Delete any DHCP configuration on initial setup
# Board-specific quirks
BOARD="$(ubus call system board | jsonfilter -e '@.model')"
case "$BOARD" in
"Bananapi BPI-R3")
uci add_list "network.br_lan.ports=wan" # Add wan port which is initially part of wan interface
;;
esac

View File

@ -23,8 +23,11 @@ cleanup() {
fetch() { fetch() {
local dl=1 local dl=1
for endpoint in $(uci get "$CONFIGSAVE".endpoints); do for endpoint in $(uci get "$CONFIGSAVE".endpoints); do
wget -T "$TIMEOUT" "$endpoint/config" -O "$CFGPATH" || continue
wget -T "$TIMEOUT" "$endpoint/checksum" -O "$CSUMPATH" || continue wget -T "$TIMEOUT" "$endpoint/checksum" -O "$CSUMPATH" || continue
local expcsum="$(cat "$CSUMPATH")"
[ "$(uci -q get "$CONFIGSAVE".lastbadcsum)" != "$expcsum" ] || break # Avoid re-fetching bad config
[ "$(uci -q get "$CONFIGSAVE".currentcsum)" != "$expcsum" ] || break # Avoid re-fetching config if checksum doesn't differ
wget -T "$TIMEOUT" "$endpoint/config" -O "$CFGPATH" || continue
dl=0 dl=0
break break
done done