mirror of
https://github.com/coolsnowwolf/luci
synced 2025-01-09 09:17:27 +08:00
parent
380e994419
commit
712e201c49
@ -9,7 +9,7 @@ LUCI_DEPENDS:=+kmod-cfg80211 +batctl-default +kmod-batman-adv +wpad-openssl +daw
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_NAME:=luci-app-easymesh
|
||||
PKG_VERSION:=1.9
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include ../../luci.mk
|
||||
|
@ -1,35 +1,37 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=99
|
||||
STOP=10
|
||||
STOP=70
|
||||
|
||||
enable=$(uci get easymesh.config.enabled 2>/dev/null)
|
||||
mesh_bat0=$(uci get network.bat0 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)
|
||||
dns=$(uci get easymesh.config.dns 2>/dev/null)
|
||||
ap_ipaddr=$(uci get network.lan.ipaddr 2>/dev/null)
|
||||
ap_ipaddr1=$(cat /etc/easymesh | sed -n '1p' 2>/dev/null)
|
||||
apRadio=$(uci get easymesh.config.apRadio 2>/dev/null)
|
||||
kvr=$(uci get easymesh.config.kvr 2>/dev/null)
|
||||
brlan=$(uci get network.@device[0].name 2>/dev/null)
|
||||
role=$(uci get easymesh.config.role 2>/dev/null)
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
ap_mode_stop(){
|
||||
ap_ipaddr=$(uci get network.lan.ipaddr 2>/dev/null)
|
||||
ap_ipaddr1=$(cat /etc/easymesh | sed -n '1p' 2>/dev/null)
|
||||
dns1=$(cat /etc/easymesh | sed -n '2p' 2>/dev/null)
|
||||
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 delete network.lan.gateway
|
||||
uci del_list network.lan.dns=$dns1
|
||||
uci -q delete network.lan.gateway
|
||||
uci -q del_list network.lan.dns=$dns1
|
||||
uci commit network
|
||||
|
||||
echo "" > /etc/easymesh
|
||||
echo "" >/etc/easymesh
|
||||
|
||||
uci delete dhcp.lan.dynamicdhcp
|
||||
uci delete dhcp.lan.ignore
|
||||
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
|
||||
@ -37,14 +39,14 @@ ap_mode_stop(){
|
||||
fi
|
||||
}
|
||||
|
||||
add_wifi_mesh(){
|
||||
mesh_nwi_mesh=$(uci get network.nwi_mesh_${apall} 2>/dev/null)
|
||||
mesh_apRadio=$(uci get wireless.mesh_${apall}.device 2>/dev/null)
|
||||
mesh_mesh=$(uci get wireless.mesh_${apall} 2>/dev/null)
|
||||
mesh_id=$(uci get easymesh.config.mesh_id 2>/dev/null)
|
||||
mobility_domain=$(uci get easymesh.config.mobility_domain 2>/dev/null)
|
||||
key=$(uci get easymesh.config.key 2>/dev/null)
|
||||
encryption=$(uci get easymesh.config.encryption 2>/dev/null)
|
||||
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
|
||||
@ -74,7 +76,7 @@ add_wifi_mesh(){
|
||||
uci commit wireless
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$encryption" != 1 ]; then
|
||||
uci set wireless.mesh_$apall.encryption='none'
|
||||
uci commit wireless
|
||||
@ -85,9 +87,9 @@ add_wifi_mesh(){
|
||||
fi
|
||||
}
|
||||
|
||||
add_kvr(){
|
||||
kvr=$(uci get easymesh.config.kvr 2>/dev/null)
|
||||
mobility_domain=$(uci get easymesh.config.mobility_domain 2>/dev/null)
|
||||
add_kvr() {
|
||||
kvr=$(uci -q get easymesh.config.kvr)
|
||||
mobility_domain=$(uci -q get easymesh.config.mobility_domain)
|
||||
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'
|
||||
@ -102,31 +104,32 @@ add_kvr(){
|
||||
uci set wireless.default_$apall.ft_psk_generate_local='1'
|
||||
uci commit wireless
|
||||
else
|
||||
uci delete wireless.default_$apall.ieee80211k
|
||||
uci delete wireless.default_$apall.ieee80211v
|
||||
uci delete wireless.default_$apall.ieee80211r
|
||||
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
|
||||
done
|
||||
}
|
||||
|
||||
add_dawn(){
|
||||
kvr=$(uci get easymesh.config.kvr 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)
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
start(){
|
||||
if [ "$enable" == 1 ]; then
|
||||
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'
|
||||
@ -137,8 +140,8 @@ start(){
|
||||
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.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'
|
||||
@ -154,7 +157,7 @@ start(){
|
||||
else
|
||||
uci set network.bat0.gw_mode='off'
|
||||
fi
|
||||
|
||||
|
||||
if [ "$brlan" = "br-lan" ]; then
|
||||
uci add_list network.@device[0].ports='bat0'
|
||||
else
|
||||
@ -175,7 +178,7 @@ start(){
|
||||
add_kvr
|
||||
add_dawn
|
||||
|
||||
if [ "$ap_mode" == 1 ]; then
|
||||
if [ "$ap_mode" = 1 ]; then
|
||||
if [ "$ap_ipaddr" != "$ipaddr" ]; then
|
||||
uci set network.lan.ipaddr=$ipaddr
|
||||
uci set network.lan.netmask=$netmask
|
||||
@ -183,15 +186,15 @@ start(){
|
||||
uci add_list network.lan.dns=$dns
|
||||
uci commit network
|
||||
|
||||
echo "" > /etc/easymesh
|
||||
echo "$ipaddr" > /etc/easymesh
|
||||
echo "$dns" >> /etc/easymesh
|
||||
echo "" >/etc/easymesh
|
||||
echo "$ipaddr" >/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 -q delete dhcp.lan.ra
|
||||
uci -q delete dhcp.lan.dhcpv6
|
||||
uci -q delete dhcp.lan.ra_management
|
||||
uci commit dhcp
|
||||
|
||||
/etc/init.d/odhcpd stop && /etc/init.d/odhcpd disable
|
||||
@ -200,19 +203,11 @@ start(){
|
||||
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 -q delete network.bat0
|
||||
if [ "$brlan" = "br-lan" ]; then
|
||||
uci del_list network.@device[0].ports='bat0'
|
||||
uci -q del_list network.@device[0].ports='bat0'
|
||||
else
|
||||
sed -i 's/ bat0//' /etc/config/network
|
||||
fi
|
||||
@ -220,16 +215,16 @@ stop(){
|
||||
fi
|
||||
|
||||
for apall in $(uci -X show wireless | grep wifi-device | awk -F'[.=]' '{print $2}'); do
|
||||
mesh_nwi_mesh=$(uci get network.nwi_mesh_${apall} 2>/dev/null)
|
||||
mesh_mesh=$(uci get wireless.mesh_${apall} 2>/dev/null)
|
||||
|
||||
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 delete network.nwi_mesh_$apall
|
||||
uci -q delete network.nwi_mesh_$apall
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
if [ "$mesh_mesh" = "wifi-iface" ]; then
|
||||
uci delete wireless.mesh_$apall
|
||||
uci -q delete wireless.mesh_$apall
|
||||
uci commit wireless
|
||||
fi
|
||||
done
|
||||
@ -237,14 +232,21 @@ stop(){
|
||||
add_kvr
|
||||
add_dawn
|
||||
|
||||
if [ "$ap_mode" == 1 ]; then
|
||||
if [ "$ap_mode" = 1 ]; then
|
||||
ap_mode_stop
|
||||
fi
|
||||
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
/etc/init.d/network restart
|
||||
}
|
||||
|
||||
start() {
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
return 0
|
||||
}
|
||||
|
||||
restart() {
|
||||
start
|
||||
set_easymesh
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user