From fdb08b94aeb4766a121f8515343460fb9dfd144e Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 5 Nov 2023 14:53:48 +0000 Subject: [PATCH] Update 'root/etc/init.d/easymesh' --- root/etc/init.d/easymesh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/root/etc/init.d/easymesh b/root/etc/init.d/easymesh index 6fffaa3..964b545 100755 --- a/root/etc/init.d/easymesh +++ b/root/etc/init.d/easymesh @@ -301,8 +301,38 @@ uci set network.lan.gateway=$dns uci set system.@system[0].hostname=$gateway # Configure LAN bridge and add ethernet interfaces to the bridge -uci set network.lan.ifname='eth0 eth1 wan lan1 lan2 lan3' # Add ethernet interfaces and the kitchen sink here -uci set network.lan.type='bridge' +# uci set network.lan.ifname='eth0 eth1 wan lan1 lan2 lan3' # Add ethernet interfaces and the kitchen sink here +# uci set network.lan.type='bridge' + +# List of interfaces to ensure are part of the bridge +declare -a interfaces_to_check=('bat0' 'eth0' 'eth1' 'lan1' 'lan2' 'wan') + +# Load the network configuration +config_load network + +# Get the current list of bridge ports for 'br-lan' +config_get bridge_ports br-lan ports + +# Convert the list to an array +IFS=' ' +read -ra current_ports <<< "$bridge_ports" + +# Function to check and add interface to br-lan if not present +add_interface_to_bridge() { + local interface=$1 + if [[ ! " ${current_ports[*]} " =~ " ${interface} " ]]; then + # Interface not found in current bridge ports, add it + uci add_list network.br-lan.ports="$interface" + echo "Interface ${interface} added to br-lan." + else + echo "Interface ${interface} is already part of br-lan." + fi +} + +# Loop through each interface and check/add to bridge +for interface in "${interfaces_to_check[@]}"; do + add_interface_to_bridge "$interface" +done # If you also need to configure the wireless network to be part of the bridge: uci set wireless.default_$apall.network='lan' # Make sure the Wi-Fi is part of the lan network