From 73cafbf155dcec846f062a2087df14e7c865d7c8 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 15:30:38 -0500 Subject: [PATCH 1/7] Bump version and fix a few bugs to work --- Makefile | 4 +- luasrc/model/cbi/easymesh.lua | 16 +- root/easymesh/easymesh.sh | 386 +++++++++++++++++++++++++++++++++ root/etc/init.d/easymesh | 391 ---------------------------------- 4 files changed, 396 insertions(+), 401 deletions(-) create mode 100755 root/easymesh/easymesh.sh delete mode 100755 root/etc/init.d/easymesh diff --git a/Makefile b/Makefile index 2a16a2c..57d159e 100755 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI Support for easymesh LUCI_DEPENDS:= +kmod-cfg80211 +batctl-default +kmod-batman-adv +dawn +bash -PKG_VERSION:=2.7 -PKG_RELEASE:=3 +PKG_VERSION:=2.8.0 +PKG_RELEASE:=0 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luasrc/model/cbi/easymesh.lua b/luasrc/model/cbi/easymesh.lua index 5c156c1..577aa1a 100755 --- a/luasrc/model/cbi/easymesh.lua +++ b/luasrc/model/cbi/easymesh.lua @@ -178,21 +178,21 @@ ctrl.anonymous = true ctrl.addremove = false -btnStop = ctrl:option(Button, "_btn_start", translate("Enable Easy Mesh")) -function btnStop.write() - io.popen("/etc/init.d/easymesh restart") +btnStart = ctrl:option(Button, "_btn_start", translate("Enable Easy Mesh")) +function btnStart.write() + io.popen("/root/easymesh/easymesh.sh") end -btnStart = ctrl:option(Button, "_btn_stop", translate("Disable Easy Mesh")) -function btnStart.write() - io.popen("/etc/init.d/easymesh stop") +btnStop = ctrl:option(Button, "_btn_stop", translate("Disable Easy Mesh")) +function btnStop.write() + io.popen("/root/easymesh/easymesh.sh") end function o.write(self, section, value) Flag.write(self, section, value) -- Run init start - luci.sys.call("uci commit") - luci.sys.call("/etc/init.d/easymesh start &") + -- luci.sys.call("uci commit") + -- luci.sys.call("/etc/init.d/easymesh start &") end return m \ No newline at end of file diff --git a/root/easymesh/easymesh.sh b/root/easymesh/easymesh.sh new file mode 100755 index 0000000..ef7839f --- /dev/null +++ b/root/easymesh/easymesh.sh @@ -0,0 +1,386 @@ +#!/bin/bash + +load_easymesh_config() { + enable=$(uci -q get easymesh.config.enabled) + mesh_bat0=$(uci -q get network.bat0) + ap_mode=$(uci -q get easymesh.config.ap_mode) + lan=$(uci -q get network.lan.ifname) + ipaddr=$(uci -q get easymesh.config.ipaddr) + netmask=$(uci -q get easymesh.config.netmask) + gateway=$(uci -q get easymesh.config.gateway) + dns=$(uci -q get easymesh.config.dns) + ap_ipaddr=$(uci -q get network.lan.ipaddr) + ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) + apRadio=$(uci -q get easymesh.config.apRadio) + kvr=$(uci -q get easymesh.config.kvr) + iapp=$(uci -q get easymesh.config.iapp) + brlan=$(uci -q get network.@device[0].name) + role=$(uci -q get easymesh.config.role) + backbone=$(uci get easymesh.@easymesh[0].backbone) + apname=$(uci get easymesh.@easymesh[0].apname) + appass=$(uci get easymesh.@easymesh[0].appass) +} + +ap_mode_stop() { + ap_ipaddr=$(uci -q get network.lan.ipaddr) + ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) + dns1=$(sed -n '2p' /etc/easymesh 2>/dev/null) + if [ "$ap_ipaddr" = "$ap_ipaddr1" ]; then + uci -q delete network.lan.gateway + uci -q del_list network.lan.dns=$dns1 + uci commit network + + echo "" >/etc/easymesh + + uci -q delete dhcp.lan.dynamicdhcp + uci -q delete dhcp.lan.ignore + uci commit dhcp + + /etc/init.d/odhcpd enable && /etc/init.d/odhcpd start + /etc/init.d/firewall enable && /etc/init.d/firewall start >/dev/null 2>&1 + fi +} + +add_wifi_mesh() { + mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) + mesh_apRadio=$(uci -q get wireless.mesh_${apall}.device) + mesh_mesh=$(uci -q get wireless.mesh_${apall}) + mesh_id=$(uci -q get easymesh.config.mesh_id) + mobility_domain=$(uci -q get easymesh.config.mobility_domain) + key=$(uci -q get easymesh.config.key) + encryption=$(uci -q get easymesh.config.encryption) + # Print out all the variables + echo "mesh_nwi_mesh: $mesh_nwi_mesh\nmesh_apRadio: $mesh_apRadio\nmesh_mesh: $mesh_mesh\nmesh_id: $mesh_id\nmobility_domain: $mobility_domain\nkey: $key\nencryption: $encryption" > /root/.newmesh + + + if [ "$mesh_nwi_mesh" != "interface" ]; then + uci set network.nwi_mesh_$apall=interface + uci set network.nwi_mesh_$apall.proto='batadv_hardif' + uci set network.nwi_mesh_$apall.master='bat0' + uci set network.nwi_mesh_$apall.mtu='1536' + # adding batman to the 'lan' zone in fw + uci del_list firewall.lan.network="bat0" + uci add_list firewall.lan.network='bat0' + uci del_list firewall.lan.network="nwi_mesh_$apall" + uci add_list firewall.lan.network="nwi_mesh_$apall" + uci commit network + uci commit firewall + /etc/init.d/firewall restart + fi + + if [ "$mesh_mesh" != "wifi-iface" ]; then + uci set wireless.mesh_$apall=wifi-iface + uci set wireless.mesh_$apall.device=$apall + uci set wireless.mesh_$apall.ifname=mesh_${apall} + uci set wireless.mesh_$apall.network=nwi_mesh_${apall} + uci set wireless.mesh_$apall.mode='mesh' + uci set wireless.mesh_$apall.mesh_id=$mesh_id + uci set wireless.mesh_$apall.mesh_fwding='1' + uci set wireless.mesh_$apall.mesh_ttl='1' + uci set wireless.mesh_$apall.mcast_rate='24000' + uci set wireless.mesh_$apall.disabled='0' + uci commit wireless + fi + + if [ "$mesh_mesh" = "wifi-iface" ]; then + if [ "$mesh_apRadio" != "$apall" ]; then + uci set wireless.mesh_$apall.device=$apall + uci commit wireless + fi + fi + + if [ "$encryption" != 1 ]; then + apnum="${mesh_apRadio#radio}" + apnum=$((apnum + 1)) + found=0 + + # Check all existing wifinetX and remove if SSID matches with $mesh_id and mode is 'ap' + while uci get wireless.wifinet$apnum > /dev/null 2>&1; do + existing_ssid=$(uci get wireless.wifinet$apnum.ssid 2> /dev/null) + existing_mode=$(uci get wireless.wifinet$apnum.mode 2> /dev/null) + if [ "$existing_ssid" = "$mesh_id" ] && [ "$existing_mode" = "ap" ]; then + if [ $found -eq 0 ]; then + found=1 + else + uci delete wireless.wifinet$apnum + fi + fi + apnum=$((apnum + 1)) + done + uci commit wireless + + if [ $found -eq 0 ]; then + uci set wireless.mesh_$apall.encryption='none' + # uci set wireless.mesh_$apall.disabled='0' + uci set wireless.wifinet$apnum=wifi-iface + uci set wireless.wifinet$apnum.device=$mesh_apRadio + uci set wireless.wifinet$apnum.mode='ap' + uci set wireless.wifinet$apnum.ssid=$mesh_id + uci set wireless.wifinet$apnum.encryption='none' + uci set wireless.wifinet$apnum.key=$key + uci set wireless.wifinet$apnum.ieee80211r='1' + uci set wireless.wifinet$apnum.mobility_domain=$mobility_domain + uci set wireless.wifinet$apnum.ft_over_ds='0' + uci set wireless.wifinet$apnum.ft_psk_generate_local='1' + uci set wireless.wifinet$apnum.network='lan' + uci set wireless.wifinet$apnum.disabled=0 + uci commit wireless + fi + + else + apnum="${mesh_apRadio#radio}" + apnum=$((apnum + 1)) + found=0 + + # Check all existing wifinetX and remove if SSID matches with $mesh_id and mode is 'ap' + while uci get wireless.wifinet$apnum > /dev/null 2>&1; do + existing_ssid=$(uci get wireless.wifinet$apnum.ssid 2> /dev/null) + existing_mode=$(uci get wireless.wifinet$apnum.mode 2> /dev/null) + if [ "$existing_ssid" = "$mesh_id" ] && [ "$existing_mode" = "ap" ]; then + if [ $found -eq 0 ]; then + found=1 + else + uci delete wireless.wifinet$apnum + fi + fi + apnum=$((apnum + 1)) + done + uci commit wireless + + if [ $found -eq 0 ]; then + uci set wireless.mesh_$apall.encryption='sae' + # uci set wireless.mesh_$apall.disabled='0' + uci set wireless.mesh_$apall.key=$key + uci set wireless.wifinet$apnum=wifi-iface + uci set wireless.wifinet$apnum.device=$apall + uci set wireless.wifinet$apnum.mode='ap' + uci set wireless.wifinet$apnum.ssid=$mesh_id + uci set wireless.wifinet$apnum.encryption='psk2' + uci set wireless.wifinet$apnum.key=$key + uci set wireless.wifinet$apnum.ieee80211r='1' + uci set wireless.wifinet$apnum.mobility_domain=$mobility_domain + uci set wireless.wifinet$apnum.ft_over_ds='0' + uci set wireless.wifinet$apnum.ft_psk_generate_local='1' + uci set wireless.wifinet$apnum.network='lan' + uci set wireless.wifinet$apnum.disabled=0 + uci commit wireless + fi +fi + +} + +add_kvr() { + kvr=$(uci -q get easymesh.config.kvr) + mobility_domain=$(uci -q get easymesh.config.mobility_domain) + iapp=$(uci -q get easymesh.config.iapp) + for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do + if [ "$kvr" = 1 ]; then + uci set wireless.default_$apall.ieee80211k='1' + uci set wireless.default_$apall.rrm_neighbor_report='1' + uci set wireless.default_$apall.rrm_beacon_report='1' + uci set wireless.default_$apall.ieee80211v='1' + uci set wireless.default_$apall.bss_transition='1' + uci set wireless.default_$apall.ieee80211r='1' + uci set wireless.default_$apall.encryption='sae' + uci set wireless.default_$apall.mobility_domain=$mobility_domain + uci set wireless.default_$apall.ft_over_ds='1' + uci set wireless.default_$apall.ft_psk_generate_local='1' + uci commit wireless + else + uci -q delete wireless.default_$apall.ieee80211k + uci -q delete wireless.default_$apall.ieee80211v + uci -q delete wireless.default_$apall.ieee80211r + uci commit wireless + fi + if [ "$iapp" = 1 ]; then + uci set wireless.default_$apall.iapp_interface='br-lan' + uci commit wireless + else + uci -q delete wireless.default_$apall.iapp_interface + uci commit wireless + fi + done +} + +add_dawn() { + kvr=$(uci -q get easymesh.config.kvr) + rssi_val=$(uci -q get easymesh.config.rssi_val) + low_rssi_val=$(uci -q get easymesh.config.low_rssi_val) + + if [ "$kvr" = 1 ]; then + uci set dawn.@metric[0].rssi_val=$rssi_val + uci set dawn.@metric[0].low_rssi_val=$low_rssi_val + uci commit dawn + /etc/init.d/dawn enable && /etc/init.d/dawn start + else + /etc/init.d/dawn stop && /etc/init.d/dawn disable + fi +} + +set_easymesh() { + if [ "$enable" = 1 ]; then + if [ "$mesh_bat0" != "interface" ]; then + uci set network.bat0=interface + uci set network.bat0.proto='batadv' + uci set network.bat0.routing_algo='BATMAN_IV' + uci set network.bat0.aggregated_ogms='1' + uci set network.bat0.ap_isolation='0' + uci set network.bat0.bonding='1' + uci set network.bat0.bridge_loop_avoidance='1' + uci set network.bat0.distributed_arp_table='1' + uci set network.bat0.fragmentation='1' + # uci set network.bat0.gw_bandwidth='10000/2000' + # uci set network.bat0.gw_sel_class='20' + uci set network.bat0.hop_penalty='30' + uci set network.bat0.isolation_mark='0x00000000/0x00000000' + uci set network.bat0.log_level='0' + uci set network.bat0.multicast_fanout='16' + uci set network.bat0.multicast_mode='1' + uci set network.bat0.network_coding='0' + uci set network.bat0.orig_interval='1000' + + + if [ "$role" = "server" ]; then + uci set network.bat0.gw_mode='server' + elif [ "$role" = "client" ]; then + uci set network.bat0.gw_mode='client' + else + uci set network.bat0.gw_mode='off' + fi + + if [ "$brlan" = "br-lan" ]; then + uci add_list network.@device[0].ports='bat0' + else + uci set network.lan.ifname="${lan} bat0" + fi + + uci commit network + fi # end [ "$mesh_bat0" != "interface" ] + + # When this is called, the add_wifi_mesh function does not load variables properly + # if [ "$apRadio" = "all" ]; then + # for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do + # add_wifi_mesh + # done + # else + # apall=$apRadio + # add_wifi_mesh + # fi + + add_kvr + add_dawn + + if [ "$ap_mode" = 1 ]; then + # Backup Configurations if your scared + cp /etc/config/wireless /etc/config/wireless.backup + cp /etc/config/network /etc/config/network.backup + cp /etc/config/dhcp /etc/config/dhcp.backup + + # Generate a random IP in the same subnet for fun + ip_base=$(echo "$dns" | cut -d'.' -f1-3) # Get the first three octets of the DNS IP + last_octet=$((RANDOM % 254 + 1)) # Generate a random value for the last octet between 1 and 254 + nodeip="${ip_base}.${last_octet}" # Concatenate the base IP with the new last octet + + # random static IP just in case + #uci set network.lan.ipaddr=$nodeip # Set the randomly chosen IP + + # Do not need these running + for i in firewall dnsmasq odhcpd; do + if /etc/init.d/"$i" enabled; then + /etc/init.d/"$i" disable + /etc/init.d/"$i" stop + fi + done + + # Set LAN interface to DHCP client + uci set network.lan.proto='dhcp' + uci delete network.wan + uci delete network.wan6 + uci delete network.lan.ipaddr + uci delete network.lan.netmask + + # Set netmask and gateway (assuming $netmask and $dns didn't break more stuff) + uci set network.lan.netmask=$netmask + uci set network.lan.gateway=$dns + uci set system.@system[0].hostname=$gateway + + # First, delete the existing interface list from br-lan + uci -q delete network.lan.ifname + + # Configure LAN bridge and add ethernet interfaces to the bridge + uci set network.lan.ifname='eth0 eth1 wan lan1 lan2' # Add ethernet and wan + uci set network.lan.type='bridge' + + # 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 + + # Commit all changes + uci commit network + uci commit system + + # In case of separate wireless config, commit that too + uci commit wireless + + # Restart the network to apply changes + /etc/init.d/network restart + /etc/init.d/system reload + + # restart wifi + wifi reload + wifi up + + # Removing firewall configuration + mv /etc/config/firewall /etc/config/firewall.unused + + else + ap_mode_stop + fi # end if [ "$ap_mode" = 1 ] + + if [ "$mesh_bat0" = "interface" ]; then + uci -q delete network.bat0 + if [ "$brlan" = "br-lan" ]; then + uci -q del_list network.@device[0].ports='bat0' + else + sed -i 's/ bat0//' /etc/config/network + fi + uci commit network + fi + + for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do + mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) + mesh_mesh=$(uci -q get wireless.mesh_${apall}) + + if [ "$mesh_nwi_mesh" = "interface" ]; then + uci -q delete network.nwi_mesh_$apall + uci commit network + fi + + if [ "$mesh_mesh" = "wifi-iface" ]; then + uci -q delete wireless.mesh_$apall + uci commit wireless + fi + done + + add_kvr + add_dawn + + if [ "$ap_mode" = 1 ]; then + ap_mode_stop + fi + fi + /etc/init.d/network restart +} # end set_easymesh() + +# Call our functions set above +load_easymesh_config +set_easymesh + +if [ "$apRadio" = "all" ]; then + for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do + add_wifi_mesh + done +else + apall=$apRadio + add_wifi_mesh +fi + diff --git a/root/etc/init.d/easymesh b/root/etc/init.d/easymesh deleted file mode 100755 index 496daaf..0000000 --- a/root/etc/init.d/easymesh +++ /dev/null @@ -1,391 +0,0 @@ -#!/bin/bash /etc/rc.common - -START=99 -STOP=70 - -load_easymesh_config() { - enable=$(uci -q get easymesh.config.enabled) - mesh_bat0=$(uci -q get network.bat0) - ap_mode=$(uci -q get easymesh.config.ap_mode) - lan=$(uci -q get network.lan.ifname) - ipaddr=$(uci -q get easymesh.config.ipaddr) - netmask=$(uci -q get easymesh.config.netmask) - gateway=$(uci -q get easymesh.config.gateway) - dns=$(uci -q get easymesh.config.dns) - ap_ipaddr=$(uci -q get network.lan.ipaddr) - ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) - apRadio=$(uci -q get easymesh.config.apRadio) - kvr=$(uci -q get easymesh.config.kvr) - iapp=$(uci -q get easymesh.config.iapp) - brlan=$(uci -q get network.@device[0].name) - role=$(uci -q get easymesh.config.role) - backbone=$(uci get easymesh.@easymesh[0].backbone) - apname=$(uci get easymesh.@easymesh[0].apname) - appass=$(uci get easymesh.@easymesh[0].appass) -} - -ap_mode_stop() { - ap_ipaddr=$(uci -q get network.lan.ipaddr) - ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) - dns1=$(sed -n '2p' /etc/easymesh 2>/dev/null) - if [ "$ap_ipaddr" = "$ap_ipaddr1" ]; then - uci -q delete network.lan.gateway - uci -q del_list network.lan.dns=$dns1 - uci commit network - - echo "" >/etc/easymesh - - uci -q delete dhcp.lan.dynamicdhcp - uci -q delete dhcp.lan.ignore - uci commit dhcp - - /etc/init.d/odhcpd enable && /etc/init.d/odhcpd start - /etc/init.d/firewall enable && /etc/init.d/firewall start >/dev/null 2>&1 - fi -} - -add_wifi_mesh() { - mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) - mesh_apRadio=$(uci -q get wireless.mesh_${apall}.device) - mesh_mesh=$(uci -q get wireless.mesh_${apall}) - mesh_id=$(uci -q get easymesh.config.mesh_id) - mobility_domain=$(uci -q get easymesh.config.mobility_domain) - key=$(uci -q get easymesh.config.key) - encryption=$(uci -q get easymesh.config.encryption) - - if [ "$mesh_nwi_mesh" != "interface" ]; then - uci set network.nwi_mesh_$apall=interface - uci set network.nwi_mesh_$apall.proto='batadv_hardif' - uci set network.nwi_mesh_$apall.master='bat0' - uci set network.nwi_mesh_$apall.mtu='1536' - # adding batman to the 'lan' zone in fw - uci del_list firewall.lan.network="bat0" - uci add_list firewall.lan.network='bat0' - uci del_list firewall.lan.network="nwi_mesh_$apall" - uci add_list firewall.lan.network="nwi_mesh_$apall" - uci commit network - uci commit firewall - /etc/init.d/firewall restart - fi - - if [ "$mesh_mesh" != "wifi-iface" ]; then - uci set wireless.mesh_$apall=wifi-iface - uci set wireless.mesh_$apall.device=$apall - uci set wireless.mesh_$apall.ifname=mesh_${apall} - uci set wireless.mesh_$apall.network=nwi_mesh_${apall} - uci set wireless.mesh_$apall.mode='mesh' - uci set wireless.mesh_$apall.mesh_id=$mesh_id - uci set wireless.mesh_$apall.mesh_fwding='1' - uci set wireless.mesh_$apall.mesh_ttl='1' - uci set wireless.mesh_$apall.mcast_rate='24000' - uci set wireless.mesh_$apall.disabled='0' - uci commit wireless - fi - - if [ "$mesh_mesh" = "wifi-iface" ]; then - if [ "$mesh_apRadio" != "$apall" ]; then - uci set wireless.mesh_$apall.device=$apall - uci commit wireless - fi - fi - - -if [ "$encryption" != 1 ]; then - apnum="${mesh_apRadio#radio}" - apnum=$((apnum + 1)) - found=0 - -# # Check all existing wifinetX and remove if SSID matches with $mesh_id and mode is 'ap' -# while uci get wireless.wifinet$apnum > /dev/null 2>&1; do -# existing_ssid=$(uci get wireless.wifinet$apnum.ssid 2> /dev/null) -# existing_mode=$(uci get wireless.wifinet$apnum.mode 2> /dev/null) -# if [ "$existing_ssid" = "$mesh_id" ] && [ "$existing_mode" = "ap" ]; then -# if [ $found -eq 0 ]; then -# found=1 -# else -# uci delete wireless.wifinet$apnum -# fi -# fi -# apnum=$((apnum + 1)) -# done -# uci commit wireless - - - if [ $found -eq 0 ]; then - uci set wireless.mesh_$apall.encryption='none' -# uci set wireless.mesh_$apall.disabled='0' - uci set wireless.wifinet$apnum=wifi-iface - uci set wireless.wifinet$apnum.device=$mesh_apRadio - uci set wireless.wifinet$apnum.mode='ap' - uci set wireless.wifinet$apnum.ssid=$mesh_id - uci set wireless.wifinet$apnum.encryption='none' - uci set wireless.wifinet$apnum.key=$key - uci set wireless.wifinet$apnum.ieee80211r='1' - uci set wireless.wifinet$apnum.mobility_domain=$mobility_domain - uci set wireless.wifinet$apnum.ft_over_ds='0' - uci set wireless.wifinet$apnum.ft_psk_generate_local='1' - uci set wireless.wifinet$apnum.network='lan' - uci set wireless.wifinet$apnum.disabled=0 - uci commit wireless - fi - -else - apnum="${mesh_apRadio#radio}" - apnum=$((apnum + 1)) - found=0 - - # # Check all existing wifinetX and remove if SSID matches with $mesh_id and mode is 'ap' - # while uci get wireless.wifinet$apnum > /dev/null 2>&1; do - # existing_ssid=$(uci get wireless.wifinet$apnum.ssid 2> /dev/null) - # existing_mode=$(uci get wireless.wifinet$apnum.mode 2> /dev/null) - # if [ "$existing_ssid" = "$mesh_id" ] && [ "$existing_mode" = "ap" ]; then - # if [ $found -eq 0 ]; then - # found=1 - # else - # uci delete wireless.wifinet$apnum - # fi - # fi - # apnum=$((apnum + 1)) - # done - # uci commit wireless - - if [ $found -eq 0 ]; then - uci set wireless.mesh_$apall.encryption='sae' -# uci set wireless.mesh_$apall.disabled='0' - uci set wireless.mesh_$apall.key=$key - uci set wireless.wifinet$apnum=wifi-iface - uci set wireless.wifinet$apnum.device=$apall - uci set wireless.wifinet$apnum.mode='ap' - uci set wireless.wifinet$apnum.ssid=$mesh_id - uci set wireless.wifinet$apnum.encryption='sae-mixed' - uci set wireless.wifinet$apnum.key=$key - uci set wireless.wifinet$apnum.ieee80211r='1' - uci set wireless.wifinet$apnum.mobility_domain=$mobility_domain - uci set wireless.wifinet$apnum.ft_over_ds='0' - uci set wireless.wifinet$apnum.ft_psk_generate_local='1' - uci set wireless.wifinet$apnum.network='lan' - uci set wireless.wifinet$apnum.disabled=0 - uci commit wireless - fi -fi - -} - -add_kvr() { - kvr=$(uci -q get easymesh.config.kvr) - mobility_domain=$(uci -q get easymesh.config.mobility_domain) - iapp=$(uci -q get easymesh.config.iapp) - for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - if [ "$kvr" = 1 ]; then - uci set wireless.default_$apall.ieee80211k='1' - uci set wireless.default_$apall.rrm_neighbor_report='1' - uci set wireless.default_$apall.rrm_beacon_report='1' - uci set wireless.default_$apall.ieee80211v='1' - uci set wireless.default_$apall.bss_transition='1' - uci set wireless.default_$apall.ieee80211r='1' - uci set wireless.default_$apall.encryption='sae' - uci set wireless.default_$apall.mobility_domain=$mobility_domain - uci set wireless.default_$apall.ft_over_ds='1' - uci set wireless.default_$apall.ft_psk_generate_local='1' - uci commit wireless - else - uci -q delete wireless.default_$apall.ieee80211k - uci -q delete wireless.default_$apall.ieee80211v - uci -q delete wireless.default_$apall.ieee80211r - uci commit wireless - fi - if [ "$iapp" = 1 ]; then - uci set wireless.default_$apall.iapp_interface='br-lan' - uci commit wireless - else - uci -q delete wireless.default_$apall.iapp_interface - uci commit wireless - fi - done -} - -add_dawn() { - kvr=$(uci -q get easymesh.config.kvr) - rssi_val=$(uci -q get easymesh.config.rssi_val) - low_rssi_val=$(uci -q get easymesh.config.low_rssi_val) - - if [ "$kvr" = 1 ]; then - uci set dawn.@metric[0].rssi_val=$rssi_val - uci set dawn.@metric[0].low_rssi_val=$low_rssi_val - uci commit dawn - /etc/init.d/dawn enable && /etc/init.d/dawn start - else - /etc/init.d/dawn stop && /etc/init.d/dawn disable - fi -} - -set_easymesh() { - load_easymesh_config - if [ "$enable" = 1 ]; then - if [ "$mesh_bat0" != "interface" ]; then - uci set network.bat0=interface - uci set network.bat0.proto='batadv' - uci set network.bat0.routing_algo='BATMAN_IV' - uci set network.bat0.aggregated_ogms='1' - uci set network.bat0.ap_isolation='0' - uci set network.bat0.bonding='1' - uci set network.bat0.bridge_loop_avoidance='1' - uci set network.bat0.distributed_arp_table='1' - uci set network.bat0.fragmentation='1' - # uci set network.bat0.gw_bandwidth='10000/2000' - # uci set network.bat0.gw_sel_class='20' - uci set network.bat0.hop_penalty='30' - uci set network.bat0.isolation_mark='0x00000000/0x00000000' - uci set network.bat0.log_level='0' - uci set network.bat0.multicast_fanout='16' - uci set network.bat0.multicast_mode='1' - uci set network.bat0.network_coding='0' - uci set network.bat0.orig_interval='1000' - - - if [ "$role" = "server" ]; then - uci set network.bat0.gw_mode='server' - elif [ "$role" = "client" ]; then - uci set network.bat0.gw_mode='client' - else - uci set network.bat0.gw_mode='off' - fi - - if [ "$brlan" = "br-lan" ]; then - uci add_list network.@device[0].ports='bat0' - else - uci set network.lan.ifname="${lan} bat0" - fi - uci commit network - fi - - if [ "$apRadio" = "all" ]; then - for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - add_wifi_mesh - done - else - apall=$apRadio - add_wifi_mesh - fi - - add_kvr - add_dawn - - - -if [ "$ap_mode" = 1 ]; then -# Backup Configurations if your scared -cp /etc/config/wireless /etc/config/wireless.backup -cp /etc/config/network /etc/config/network.backup -cp /etc/config/dhcp /etc/config/dhcp.backup - -# Generate a random IP in the same subnet for fun -ip_base=$(echo "$dns" | cut -d'.' -f1-3) # Get the first three octets of the DNS IP -last_octet=$((RANDOM % 254 + 1)) # Generate a random value for the last octet between 1 and 254 -nodeip="${ip_base}.${last_octet}" # Concatenate the base IP with the new last octet - -# random static IP just in case -#uci set network.lan.ipaddr=$nodeip # Set the randomly chosen IP - -# Do not need these running -for i in firewall dnsmasq odhcpd; do - if /etc/init.d/"$i" enabled; then - /etc/init.d/"$i" disable - /etc/init.d/"$i" stop - fi -done - -# Set LAN interface to DHCP client -uci set network.lan.proto='dhcp' -uci delete network.wan -uci delete network.wan6 -uci delete network.lan.ipaddr -uci delete network.lan.netmask - -# Set netmask and gateway (assuming $netmask and $dns didn't break more stuff) -uci set network.lan.netmask=$netmask -uci set network.lan.gateway=$dns -uci set system.@system[0].hostname=$gateway - -# First, delete the existing interface list from br-lan -uci -q delete network.lan.ifname - -# Configure LAN bridge and add ethernet interfaces to the bridge -uci set network.lan.ifname='eth0 eth1 wan lan1 lan2' # Add ethernet and wan -uci set network.lan.type='bridge' - -# 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 - -# Commit all changes -uci commit network -uci commit system - -# In case of separate wireless config, commit that too -uci commit wireless - -# Restart the network to apply changes -/etc/init.d/network restart -/etc/init.d/system reload - -# restart wifi -wifi reload -wifi up - -# Removing firewall configuration -mv /etc/config/firewall /etc/config/firewall.unused - -#fi - - - else - ap_mode_stop - fi - - if [ "$mesh_bat0" = "interface" ]; then - uci -q delete network.bat0 - if [ "$brlan" = "br-lan" ]; then - uci -q del_list network.@device[0].ports='bat0' - else - sed -i 's/ bat0//' /etc/config/network - fi - uci commit network - fi - - for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) - mesh_mesh=$(uci -q get wireless.mesh_${apall}) - - if [ "$mesh_nwi_mesh" = "interface" ]; then - uci -q delete network.nwi_mesh_$apall - uci commit network - fi - - if [ "$mesh_mesh" = "wifi-iface" ]; then - uci -q delete wireless.mesh_$apall - uci commit wireless - fi - done - - add_kvr - add_dawn - - if [ "$ap_mode" = 1 ]; then - ap_mode_stop - fi - fi - /etc/init.d/network restart -} - -start() { - return 0 -} - -stop() { - return 0 -} - -restart() { - set_easymesh - add_wifi_mesh -} -- 2.38.4 From d8b557d107429e1fb2daa6885ee1d305f4d8f8cc Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 15:47:56 -0500 Subject: [PATCH 2/7] Fix script location --- Makefile | 2 +- luasrc/model/cbi/easymesh.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 57d159e..d4fb321 100755 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI Support for easymesh LUCI_DEPENDS:= +kmod-cfg80211 +batctl-default +kmod-batman-adv +dawn +bash -PKG_VERSION:=2.8.0 +PKG_VERSION:=2.8.1 PKG_RELEASE:=0 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luasrc/model/cbi/easymesh.lua b/luasrc/model/cbi/easymesh.lua index 577aa1a..d317a87 100755 --- a/luasrc/model/cbi/easymesh.lua +++ b/luasrc/model/cbi/easymesh.lua @@ -180,12 +180,12 @@ ctrl.addremove = false btnStart = ctrl:option(Button, "_btn_start", translate("Enable Easy Mesh")) function btnStart.write() - io.popen("/root/easymesh/easymesh.sh") + io.popen("/easymesh/easymesh.sh") end btnStop = ctrl:option(Button, "_btn_stop", translate("Disable Easy Mesh")) function btnStop.write() - io.popen("/root/easymesh/easymesh.sh") + io.popen("/easymesh/easymesh.sh") end function o.write(self, section, value) -- 2.38.4 From 26e57ec5b24a61e6b4cc4d8dfdb1bf7c4d692a66 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 22:01:44 -0500 Subject: [PATCH 3/7] Testing Push --- luasrc/model/cbi/easymesh.lua | 2 +- root/easymesh/easymesh.sh | 183 ++++++++++++++++------------------ 2 files changed, 89 insertions(+), 96 deletions(-) diff --git a/luasrc/model/cbi/easymesh.lua b/luasrc/model/cbi/easymesh.lua index d317a87..cf167d8 100755 --- a/luasrc/model/cbi/easymesh.lua +++ b/luasrc/model/cbi/easymesh.lua @@ -154,7 +154,7 @@ o.default = "192.168.8.1" o.datatype = "ip4addr" o:depends("ap_mode", 1) -so = s:option(Value, "netmask", translate("IPv4 netmask")) +o = s:option(Value, "netmask", translate("IPv4 netmask")) o.default = "255.255.255.0" o.datatype = "ip4addr" o:depends("ap_mode", 1) diff --git a/root/easymesh/easymesh.sh b/root/easymesh/easymesh.sh index ef7839f..e6c1557 100755 --- a/root/easymesh/easymesh.sh +++ b/root/easymesh/easymesh.sh @@ -19,6 +19,8 @@ load_easymesh_config() { backbone=$(uci get easymesh.@easymesh[0].backbone) apname=$(uci get easymesh.@easymesh[0].apname) appass=$(uci get easymesh.@easymesh[0].appass) + # On a single line, print all of the variables to a file + printf "enable: $enable\nmesh_bat0: $mesh_bat0\nap_mode: $ap_mode\nlan: $lan\nipaddr: $ipaddr\nnetmask: $netmask\ngateway: $gateway\ndns: $dns\nap_ipaddr: $ap_ipaddr\nap_ipaddr1: $ap_ipaddr1\napRadio: $apRadio\nkvr: $kvr\niapp: $iapp\nbrlan: $brlan\nrole: $role\nbackbone: $backbone\napname: $apname\nappass: $appass" > /root/.easymesh } ap_mode_stop() { @@ -50,7 +52,7 @@ add_wifi_mesh() { key=$(uci -q get easymesh.config.key) encryption=$(uci -q get easymesh.config.encryption) # Print out all the variables - echo "mesh_nwi_mesh: $mesh_nwi_mesh\nmesh_apRadio: $mesh_apRadio\nmesh_mesh: $mesh_mesh\nmesh_id: $mesh_id\nmobility_domain: $mobility_domain\nkey: $key\nencryption: $encryption" > /root/.newmesh + printf "mesh_nwi_mesh: $mesh_nwi_mesh\nmesh_apRadio: $mesh_apRadio\nmesh_mesh: $mesh_mesh\nmesh_id: $mesh_id\nmobility_domain: $mobility_domain\nkey: $key\nencryption: $encryption" > /root/.newmesh if [ "$mesh_nwi_mesh" != "interface" ]; then @@ -69,24 +71,24 @@ add_wifi_mesh() { fi if [ "$mesh_mesh" != "wifi-iface" ]; then - uci set wireless.mesh_$apall=wifi-iface - uci set wireless.mesh_$apall.device=$apall - uci set wireless.mesh_$apall.ifname=mesh_${apall} - uci set wireless.mesh_$apall.network=nwi_mesh_${apall} - uci set wireless.mesh_$apall.mode='mesh' - uci set wireless.mesh_$apall.mesh_id=$mesh_id - uci set wireless.mesh_$apall.mesh_fwding='1' - uci set wireless.mesh_$apall.mesh_ttl='1' - uci set wireless.mesh_$apall.mcast_rate='24000' - uci set wireless.mesh_$apall.disabled='0' - uci commit wireless + uci set wireless.mesh_$apall=wifi-iface + uci set wireless.mesh_$apall.device=$apall + uci set wireless.mesh_$apall.ifname=mesh_${apall} + uci set wireless.mesh_$apall.network=nwi_mesh_${apall} + uci set wireless.mesh_$apall.mode='mesh' + uci set wireless.mesh_$apall.mesh_id=$mesh_id + uci set wireless.mesh_$apall.mesh_fwding='1' + uci set wireless.mesh_$apall.mesh_ttl='1' + uci set wireless.mesh_$apall.mcast_rate='24000' + uci set wireless.mesh_$apall.disabled='0' + uci commit wireless fi if [ "$mesh_mesh" = "wifi-iface" ]; then - if [ "$mesh_apRadio" != "$apall" ]; then - uci set wireless.mesh_$apall.device=$apall - uci commit wireless - fi + if [ "$mesh_apRadio" != "$apall" ]; then + uci set wireless.mesh_$apall.device=$apall + uci commit wireless + fi fi if [ "$encryption" != 1 ]; then @@ -155,7 +157,7 @@ add_wifi_mesh() { uci set wireless.wifinet$apnum.device=$apall uci set wireless.wifinet$apnum.mode='ap' uci set wireless.wifinet$apnum.ssid=$mesh_id - uci set wireless.wifinet$apnum.encryption='psk2' + uci set wireless.wifinet$apnum.encryption='sae-mixed' uci set wireless.wifinet$apnum.key=$key uci set wireless.wifinet$apnum.ieee80211r='1' uci set wireless.wifinet$apnum.mobility_domain=$mobility_domain @@ -170,51 +172,51 @@ fi } add_kvr() { - kvr=$(uci -q get easymesh.config.kvr) - mobility_domain=$(uci -q get easymesh.config.mobility_domain) - iapp=$(uci -q get easymesh.config.iapp) - for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - if [ "$kvr" = 1 ]; then - uci set wireless.default_$apall.ieee80211k='1' - uci set wireless.default_$apall.rrm_neighbor_report='1' - uci set wireless.default_$apall.rrm_beacon_report='1' - uci set wireless.default_$apall.ieee80211v='1' - uci set wireless.default_$apall.bss_transition='1' - uci set wireless.default_$apall.ieee80211r='1' - uci set wireless.default_$apall.encryption='sae' - uci set wireless.default_$apall.mobility_domain=$mobility_domain - uci set wireless.default_$apall.ft_over_ds='1' - uci set wireless.default_$apall.ft_psk_generate_local='1' - uci commit wireless - else - uci -q delete wireless.default_$apall.ieee80211k - uci -q delete wireless.default_$apall.ieee80211v - uci -q delete wireless.default_$apall.ieee80211r - uci commit wireless - fi - if [ "$iapp" = 1 ]; then - uci set wireless.default_$apall.iapp_interface='br-lan' - uci commit wireless - else - uci -q delete wireless.default_$apall.iapp_interface - uci commit wireless - fi - done -} - -add_dawn() { - kvr=$(uci -q get easymesh.config.kvr) - rssi_val=$(uci -q get easymesh.config.rssi_val) - low_rssi_val=$(uci -q get easymesh.config.low_rssi_val) - + kvr=$(uci -q get easymesh.config.kvr) + mobility_domain=$(uci -q get easymesh.config.mobility_domain) + iapp=$(uci -q get easymesh.config.iapp) + for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do if [ "$kvr" = 1 ]; then - uci set dawn.@metric[0].rssi_val=$rssi_val - uci set dawn.@metric[0].low_rssi_val=$low_rssi_val - uci commit dawn - /etc/init.d/dawn enable && /etc/init.d/dawn start + uci set wireless.default_$apall.ieee80211k='1' + uci set wireless.default_$apall.rrm_neighbor_report='1' + uci set wireless.default_$apall.rrm_beacon_report='1' + uci set wireless.default_$apall.ieee80211v='1' + uci set wireless.default_$apall.bss_transition='1' + uci set wireless.default_$apall.ieee80211r='1' + uci set wireless.default_$apall.encryption='sae' + uci set wireless.default_$apall.mobility_domain=$mobility_domain + uci set wireless.default_$apall.ft_over_ds='1' + uci set wireless.default_$apall.ft_psk_generate_local='1' + uci commit wireless else - /etc/init.d/dawn stop && /etc/init.d/dawn disable + uci -q delete wireless.default_$apall.ieee80211k + uci -q delete wireless.default_$apall.ieee80211v + uci -q delete wireless.default_$apall.ieee80211r + uci commit wireless fi + if [ "$iapp" = 1 ]; then + uci set wireless.default_$apall.iapp_interface='br-lan' + uci commit wireless + else + uci -q delete wireless.default_$apall.iapp_interface + uci commit wireless + fi + done +} + +add_dawn() { + kvr=$(uci -q get easymesh.config.kvr) + rssi_val=$(uci -q get easymesh.config.rssi_val) + low_rssi_val=$(uci -q get easymesh.config.low_rssi_val) + + if [ "$kvr" = 1 ]; then + uci set dawn.@metric[0].rssi_val=$rssi_val + uci set dawn.@metric[0].low_rssi_val=$low_rssi_val + uci commit dawn + /etc/init.d/dawn enable && /etc/init.d/dawn start + else + /etc/init.d/dawn stop && /etc/init.d/dawn disable + fi } set_easymesh() { @@ -239,7 +241,6 @@ set_easymesh() { uci set network.bat0.network_coding='0' uci set network.bat0.orig_interval='1000' - if [ "$role" = "server" ]; then uci set network.bat0.gw_mode='server' elif [ "$role" = "client" ]; then @@ -258,14 +259,18 @@ set_easymesh() { fi # end [ "$mesh_bat0" != "interface" ] # When this is called, the add_wifi_mesh function does not load variables properly - # if [ "$apRadio" = "all" ]; then - # for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - # add_wifi_mesh - # done - # else - # apall=$apRadio - # add_wifi_mesh - # fi + if [ "$apRadio" = "all" ]; then + for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do + add_wifi_mesh + add_kvr + add_dawn + done + else + apall=$apRadio + add_wifi_mesh + add_kvr + add_dawn + fi add_kvr add_dawn @@ -335,7 +340,7 @@ set_easymesh() { else ap_mode_stop fi # end if [ "$ap_mode" = 1 ] - + else if [ "$mesh_bat0" = "interface" ]; then uci -q delete network.bat0 if [ "$brlan" = "br-lan" ]; then @@ -347,40 +352,28 @@ set_easymesh() { fi for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) - mesh_mesh=$(uci -q get wireless.mesh_${apall}) + mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) + mesh_mesh=$(uci -q get wireless.mesh_${apall}) - if [ "$mesh_nwi_mesh" = "interface" ]; then - uci -q delete network.nwi_mesh_$apall - uci commit network - fi + if [ "$mesh_nwi_mesh" = "interface" ]; then + uci -q delete network.nwi_mesh_$apall + uci commit network + fi - if [ "$mesh_mesh" = "wifi-iface" ]; then - uci -q delete wireless.mesh_$apall - uci commit wireless - fi + if [ "$mesh_mesh" = "wifi-iface" ]; then + uci -q delete wireless.mesh_$apall + uci commit wireless + fi done + fi - add_kvr - add_dawn - - if [ "$ap_mode" = 1 ]; then - ap_mode_stop - fi + if [ "$ap_mode" = 0 ]; then + ap_mode_stop fi + /etc/init.d/network restart } # end set_easymesh() # Call our functions set above load_easymesh_config set_easymesh - -if [ "$apRadio" = "all" ]; then - for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do - add_wifi_mesh - done -else - apall=$apRadio - add_wifi_mesh -fi - -- 2.38.4 From eddb37816e60e2aefd278c5cbf0671d3c3a92bc1 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 22:05:45 -0500 Subject: [PATCH 4/7] Add bens change --- root/easymesh/easymesh.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/root/easymesh/easymesh.sh b/root/easymesh/easymesh.sh index e6c1557..39bf027 100755 --- a/root/easymesh/easymesh.sh +++ b/root/easymesh/easymesh.sh @@ -309,11 +309,13 @@ set_easymesh() { uci set network.lan.gateway=$dns uci set system.@system[0].hostname=$gateway - # First, delete the existing interface list from br-lan - uci -q delete network.lan.ifname - # Configure LAN bridge and add ethernet interfaces to the bridge - uci set network.lan.ifname='eth0 eth1 wan lan1 lan2' # Add ethernet and wan + uci del network.@device[0].ports + uci add_list network.@device[0].ports='bat0' + uci add_list network.@device[0].ports='eth0' + uci add_list network.@device[0].ports='lan1' + uci add_list network.@device[0].ports='lan2' + uci add_list network.@device[0].ports='wan' uci set network.lan.type='bridge' # If you also need to configure the wireless network to be part of the bridge: -- 2.38.4 From b4d96ce8d33746c7b50b77f82b42c812df040b8e Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 22:07:14 -0500 Subject: [PATCH 5/7] Cleanup again --- root/easymesh/easymesh.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/root/easymesh/easymesh.sh b/root/easymesh/easymesh.sh index 39bf027..83f119a 100755 --- a/root/easymesh/easymesh.sh +++ b/root/easymesh/easymesh.sh @@ -272,9 +272,6 @@ set_easymesh() { add_dawn fi - add_kvr - add_dawn - if [ "$ap_mode" = 1 ]; then # Backup Configurations if your scared cp /etc/config/wireless /etc/config/wireless.backup -- 2.38.4 From 2bc33a566f2c1958275c7ae0bd441715353f525f Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 22:41:37 -0500 Subject: [PATCH 6/7] Jason and Riley's cleanup --- root/easymesh/easymesh.sh | 69 +++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/root/easymesh/easymesh.sh b/root/easymesh/easymesh.sh index 83f119a..ec150ea 100755 --- a/root/easymesh/easymesh.sh +++ b/root/easymesh/easymesh.sh @@ -10,7 +10,7 @@ load_easymesh_config() { gateway=$(uci -q get easymesh.config.gateway) dns=$(uci -q get easymesh.config.dns) ap_ipaddr=$(uci -q get network.lan.ipaddr) - ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) + #ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) apRadio=$(uci -q get easymesh.config.apRadio) kvr=$(uci -q get easymesh.config.kvr) iapp=$(uci -q get easymesh.config.iapp) @@ -23,25 +23,34 @@ load_easymesh_config() { printf "enable: $enable\nmesh_bat0: $mesh_bat0\nap_mode: $ap_mode\nlan: $lan\nipaddr: $ipaddr\nnetmask: $netmask\ngateway: $gateway\ndns: $dns\nap_ipaddr: $ap_ipaddr\nap_ipaddr1: $ap_ipaddr1\napRadio: $apRadio\nkvr: $kvr\niapp: $iapp\nbrlan: $brlan\nrole: $role\nbackbone: $backbone\napname: $apname\nappass: $appass" > /root/.easymesh } -ap_mode_stop() { - ap_ipaddr=$(uci -q get network.lan.ipaddr) - ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) - dns1=$(sed -n '2p' /etc/easymesh 2>/dev/null) - if [ "$ap_ipaddr" = "$ap_ipaddr1" ]; then - uci -q delete network.lan.gateway - uci -q del_list network.lan.dns=$dns1 - uci commit network +stop_node() { + cp /etc/config/wireless.meshbak /etc/config/wireless + cp /etc/config/network.meshbak /etc/config/network + cp /etc/config/dhcp.meshbak /etc/config/dhcp - echo "" >/etc/easymesh + /etc/init.d/network restart + /etc/init.d/system reload +} - uci -q delete dhcp.lan.dynamicdhcp - uci -q delete dhcp.lan.ignore - uci commit dhcp +# ap_mode_stop() { +# ap_ipaddr=$(uci -q get network.lan.ipaddr) +# ap_ipaddr1=$(sed -n '1p' /etc/easymesh 2>/dev/null) +# dns1=$(sed -n '2p' /etc/easymesh 2>/dev/null) +# if [ "$ap_ipaddr" = "$ap_ipaddr1" ]; then +# uci -q delete network.lan.gateway +# uci -q del_list network.lan.dns=$dns1 +# uci commit network - /etc/init.d/odhcpd enable && /etc/init.d/odhcpd start - /etc/init.d/firewall enable && /etc/init.d/firewall start >/dev/null 2>&1 - fi -} +# echo "" >/etc/easymesh + +# uci -q delete dhcp.lan.dynamicdhcp +# uci -q delete dhcp.lan.ignore +# uci commit dhcp + +# /etc/init.d/odhcpd enable && /etc/init.d/odhcpd start +# /etc/init.d/firewall enable && /etc/init.d/firewall start >/dev/null 2>&1 +# fi +# } add_wifi_mesh() { mesh_nwi_mesh=$(uci -q get network.nwi_mesh_${apall}) @@ -274,9 +283,9 @@ set_easymesh() { if [ "$ap_mode" = 1 ]; then # Backup Configurations if your scared - cp /etc/config/wireless /etc/config/wireless.backup - cp /etc/config/network /etc/config/network.backup - cp /etc/config/dhcp /etc/config/dhcp.backup + cp /etc/config/wireless /etc/config/wireless.meshbak + cp /etc/config/network /etc/config/network.meshbak + cp /etc/config/dhcp /etc/config/dhcp.meshbak # Generate a random IP in the same subnet for fun ip_base=$(echo "$dns" | cut -d'.' -f1-3) # Get the first three octets of the DNS IP @@ -302,8 +311,9 @@ set_easymesh() { uci delete network.lan.netmask # Set netmask and gateway (assuming $netmask and $dns didn't break more stuff) - uci set network.lan.netmask=$netmask - uci set network.lan.gateway=$dns + # Comment out because we want to pull this from dhcp + # uci set network.lan.netmask=$netmask + # uci set network.lan.gateway=$dns uci set system.@system[0].hostname=$gateway # Configure LAN bridge and add ethernet interfaces to the bridge @@ -319,11 +329,7 @@ set_easymesh() { uci set wireless.default_$apall.network='lan' # Make sure the Wi-Fi is part of the lan network # Commit all changes - uci commit network - uci commit system - - # In case of separate wireless config, commit that too - uci commit wireless + uci commit # Restart the network to apply changes /etc/init.d/network restart @@ -337,9 +343,12 @@ set_easymesh() { mv /etc/config/firewall /etc/config/firewall.unused else - ap_mode_stop + stop_node fi # end if [ "$ap_mode" = 1 ] else + # Disable the ap_mode settings + stop_node + if [ "$mesh_bat0" = "interface" ]; then uci -q delete network.bat0 if [ "$brlan" = "br-lan" ]; then @@ -366,10 +375,6 @@ set_easymesh() { done fi - if [ "$ap_mode" = 0 ]; then - ap_mode_stop - fi - /etc/init.d/network restart } # end set_easymesh() -- 2.38.4 From 544a54bfa06a05a27d30ea761373425faf374970 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Thu, 9 Nov 2023 23:19:58 -0500 Subject: [PATCH 7/7] Ben's latest fix --- root/easymesh/easymesh.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/easymesh/easymesh.sh b/root/easymesh/easymesh.sh index ec150ea..8a97d1b 100755 --- a/root/easymesh/easymesh.sh +++ b/root/easymesh/easymesh.sh @@ -325,8 +325,8 @@ set_easymesh() { uci add_list network.@device[0].ports='wan' uci set network.lan.type='bridge' - # 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 + # Make sure the Wi-Fi is part of the lan + uci set wireless.wifinet1.network='lan nwi_mesh_${apall} wwan' # Commit all changes uci commit -- 2.38.4