mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
207 lines
6.0 KiB
Bash
Executable File
207 lines
6.0 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
START=99
|
|
STOP=10
|
|
|
|
enable=$(uci get easymesh.config.enabled 2>/dev/null)
|
|
mesh_bat0=$(uci get network.bat0 2>/dev/null)
|
|
mesh_nwi_mesh0=$(uci get network.nwi_mesh0 2>/dev/null)
|
|
mesh_mesh0=$(uci get wireless.mesh0 2>/dev/null)
|
|
ap_mode=$(uci get easymesh.config.ap_mode 2>/dev/null)
|
|
lan=$(uci get network.lan.ifname 2>/dev/null)
|
|
ipaddr=$(uci get easymesh.config.ipaddr 2>/dev/null)
|
|
netmask=$(uci get easymesh.config.netmask 2>/dev/null)
|
|
gateway=$(uci get easymesh.config.gateway 2>/dev/null)
|
|
ap_gateway=$(uci get network.lan.gateway 2>/dev/null)
|
|
ap_gateway1=$(cat /etc/easymesh | sed -n '1p' 2>/dev/null)
|
|
dns1=$(cat /etc/easymesh | sed -n '2p' 2>/dev/null)
|
|
dns=$(uci get easymesh.config.dns 2>/dev/null)
|
|
mesh_id=$(uci get easymesh.config.mesh_id 2>/dev/null)
|
|
apRadio=$(uci get easymesh.config.apRadio 2>/dev/null)
|
|
mesh0_apRadio=$(uci get wireless.mesh0.device 2>/dev/null)
|
|
encryption=$(uci get easymesh.config.encryption 2>/dev/null)
|
|
key=$(uci get easymesh.config.key 2>/dev/null)
|
|
kvr=$(uci get easymesh.config.kvr 2>/dev/null)
|
|
mobility_domain=$(uci get easymesh.config.mobility_domain 2>/dev/null)
|
|
rssi_val=$(uci get easymesh.config.rssi_val 2>/dev/null)
|
|
low_rssi_val=$(uci get easymesh.config.low_rssi_val 2>/dev/null)
|
|
|
|
ap_mode_stop(){
|
|
if [ "$ap_gateway" = "$ap_gateway1" ]; then
|
|
uci delete network.lan.gateway
|
|
uci del_list network.lan.dns=$dns1
|
|
uci commit network
|
|
|
|
echo "" > /etc/easymesh
|
|
|
|
uci delete dhcp.lan.dynamicdhcp
|
|
uci 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
|
|
}
|
|
|
|
kvr_stop(){
|
|
for wifiiface in $(uci -X show wireless | grep wifi-iface | awk -F'[=]' '{print $1}'); do
|
|
if [ "${wifiiface}" != "wireless.mesh0" ]; then
|
|
uci delete ${wifiiface}.ieee80211k
|
|
uci delete ${wifiiface}.ieee80211v
|
|
uci delete ${wifiiface}.ieee80211r
|
|
uci commit network
|
|
fi
|
|
done
|
|
/etc/init.d/dawn stop && /etc/init.d/dawn disable
|
|
|
|
}
|
|
|
|
start(){
|
|
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.gw_bandwidth='10000/2000'
|
|
uci set network.bat0.ap_isolation='0'
|
|
uci set network.bat0.bonding='0'
|
|
uci set network.bat0.fragmentation='1'
|
|
uci set network.bat0.gw_mode='off'
|
|
#uci set network.bat0.gw_sel_class='20'
|
|
uci set network.bat0.log_level='0'
|
|
uci set network.bat0.orig_interval='1000'
|
|
uci set network.bat0.bridge_loop_avoidance='1'
|
|
uci set network.bat0.distributed_arp_table='1'
|
|
uci set network.bat0.multicast_mode='1'
|
|
uci set network.bat0.network_coding='0'
|
|
uci set network.bat0.hop_penalty='30'
|
|
uci set network.bat0.isolation_mark='0x00000000/0x00000000'
|
|
|
|
uci set network.lan.ifname="${lan} bat0"
|
|
uci commit network
|
|
fi
|
|
|
|
if [ "$mesh_nwi_mesh0" != "interface" ]; then
|
|
uci set network.nwi_mesh0=interface
|
|
uci set network.nwi_mesh0.proto='batadv_hardif'
|
|
uci set network.nwi_mesh0.mtu='2304'
|
|
uci set network.nwi_mesh0.master='bat0'
|
|
uci commit network
|
|
fi
|
|
|
|
if [ "$mesh_mesh0" != "wifi-iface" ]; then
|
|
uci set wireless.mesh0=wifi-iface
|
|
uci set wireless.mesh0.device=$apRadio
|
|
uci set wireless.mesh0.ifname='mesh0'
|
|
uci set wireless.mesh0.network='nwi_mesh0'
|
|
uci set wireless.mesh0.mode='mesh'
|
|
uci set wireless.mesh0.mesh_fwding='0'
|
|
uci set wireless.mesh0.mesh_id=$mesh_id
|
|
uci commit wireless
|
|
fi
|
|
|
|
if [ "$mesh_mesh0" = "wifi-iface" ]; then
|
|
if [ "$mesh0_apRadio" != "$apRadio" ]; then
|
|
uci set wireless.mesh0.device=$apRadio
|
|
uci commit wireless
|
|
fi
|
|
fi
|
|
|
|
if [ "$encryption" != 1 ]; then
|
|
uci set wireless.mesh0.encryption='none'
|
|
uci commit wireless
|
|
else
|
|
uci set wireless.mesh0.encryption='sae'
|
|
uci set wireless.mesh0.key=$key
|
|
uci commit wireless
|
|
fi
|
|
|
|
if [ "$kvr" = 1 ]; then
|
|
for wifiiface in $(uci -X show wireless | grep wifi-iface | awk -F'[=]' '{print $1}'); do
|
|
if [ "${wifiiface}" != "wireless.mesh0" ]; then
|
|
uci set ${wifiiface}.ieee80211k='1'
|
|
uci set ${wifiiface}.rrm_neighbor_report='1'
|
|
uci set ${wifiiface}.rrm_beacon_report='1'
|
|
uci set ${wifiiface}.ieee80211v='1'
|
|
uci set ${wifiiface}.bss_transition='1'
|
|
uci set ${wifiiface}.ieee80211r='1'
|
|
uci set ${wifiiface}.encryption='psk-mixed'
|
|
uci set ${wifiiface}.mobility_domain=$mobility_domain
|
|
uci set ${wifiiface}.ft_over_ds='1'
|
|
uci set ${wifiiface}.ft_psk_generate_local='1'
|
|
uci commit network
|
|
fi
|
|
done
|
|
|
|
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
|
|
kvr_stop
|
|
fi
|
|
|
|
if [ "$ap_mode" == 1 ]; then
|
|
if [ "$ap_gateway" != "$gateway" ]; then
|
|
uci set network.lan.ipaddr=$ipaddr
|
|
uci set network.lan.netmask=$netmask
|
|
uci set network.lan.gateway=$gateway
|
|
uci add_list network.lan.dns=$dns
|
|
uci commit network
|
|
|
|
echo "" > /etc/easymesh
|
|
echo "$gateway" > /etc/easymesh
|
|
echo "$dns" >> /etc/easymesh
|
|
|
|
uci set dhcp.lan.dynamicdhcp='0'
|
|
uci set dhcp.lan.ignore='1'
|
|
uci delete dhcp.lan.ra
|
|
uci delete dhcp.lan.dhcpv6
|
|
uci delete dhcp.lan.ra_management
|
|
uci commit dhcp
|
|
|
|
/etc/init.d/odhcpd stop && /etc/init.d/odhcpd disable
|
|
/etc/init.d/firewall stop && /etc/init.d/firewall disable >/dev/null 2>&1
|
|
fi
|
|
else
|
|
ap_mode_stop
|
|
fi
|
|
|
|
/etc/init.d/network restart
|
|
else
|
|
stop
|
|
fi
|
|
}
|
|
|
|
stop(){
|
|
if [ "$enable" != 1 ]; then
|
|
if [ "$mesh_bat0" = "interface" ]; then
|
|
uci delete network.bat0
|
|
uci commit network
|
|
sed -i 's/ bat0//' /etc/config/network
|
|
fi
|
|
|
|
if [ "$mesh_nwi_mesh0" = "interface" ]; then
|
|
uci delete network.nwi_mesh0
|
|
uci commit network
|
|
fi
|
|
|
|
if [ "$mesh_mesh0" = "wifi-iface" ]; then
|
|
uci delete wireless.mesh0
|
|
uci commit wireless
|
|
|
|
kvr_stop
|
|
fi
|
|
|
|
if [ "$ap_mode" == 1 ]; then
|
|
ap_mode_stop
|
|
fi
|
|
|
|
/etc/init.d/network restart
|
|
fi
|
|
}
|
|
|
|
restart() {
|
|
start
|
|
}
|