mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
luci-app-easymesh: add package from ntlf9t
This commit is contained in:
parent
89d2ce56df
commit
1bb9b83c5a
13
package/lean/luci-app-easymesh/Makefile
Executable file
13
package/lean/luci-app-easymesh/Makefile
Executable file
@ -0,0 +1,13 @@
|
||||
#
|
||||
#-- Copyright (C) 2021 dz <dingzhong110@gmail.com>
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI Support for easymesh
|
||||
LUCI_DEPENDS:= +kmod-cfg80211 +batctl-default +kmod-batman-adv +wpad-openssl
|
||||
PKG_VERSION:=1.6
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
15
package/lean/luci-app-easymesh/luasrc/controller/easymesh.lua
Executable file
15
package/lean/luci-app-easymesh/luasrc/controller/easymesh.lua
Executable file
@ -0,0 +1,15 @@
|
||||
#-- Copyright (C) 2021 dz <dingzhong110@gmail.com>
|
||||
|
||||
module("luci.controller.easymesh", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/easymesh") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
|
||||
page = entry({"admin", "network", "easymesh"}, cbi("easymesh"), _("EASY MESH"), 60)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-easymesh" }
|
||||
end
|
70
package/lean/luci-app-easymesh/luasrc/model/cbi/easymesh.lua
Executable file
70
package/lean/luci-app-easymesh/luasrc/model/cbi/easymesh.lua
Executable file
@ -0,0 +1,70 @@
|
||||
-- Copyright (C) 2021 dz <dingzhong110@gmail.com>
|
||||
|
||||
local m,s,o
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
m = Map("easymesh")
|
||||
|
||||
function detect_Node()
|
||||
local data = {}
|
||||
local lps = luci.util.execi(" batctl n 2>/dev/null | tail +2 | sed 's/^[ ][ ]*//g' | sed 's/[ ][ ]*/ /g' | sed 's/$/ /g' ")
|
||||
for value in lps do
|
||||
local row = {}
|
||||
local pos = string.find(value, " ")
|
||||
local IFA = string.sub(value, 1, pos - 1)
|
||||
local value = string.sub(value, pos + 1, string.len(value))
|
||||
pos = string.find(value, " ")
|
||||
local pos = string.find(value, " ")
|
||||
local Neighbora = string.sub(value, 1, pos - 1)
|
||||
local value = string.sub(value, pos + 1, string.len(value))
|
||||
pos = string.find(value, " ")
|
||||
local pos = string.find(value, " ")
|
||||
local lastseena = string.sub(value, 1, pos - 1)
|
||||
local value = string.sub(value, pos + 1, string.len(value))
|
||||
pos = string.find(value, " ")
|
||||
row["IF"] = IFA
|
||||
row["Neighbor"] = Neighbora
|
||||
row["lastseen"] = lastseena
|
||||
table.insert(data, row)
|
||||
end
|
||||
return data
|
||||
end
|
||||
local Nodes = luci.sys.exec("batctl n 2>/dev/null| tail +3 | wc -l")
|
||||
local Node = detect_Node()
|
||||
v = m:section(Table, Node, "" ,translate("<b>Active node:" .. Nodes .. "</b>"))
|
||||
v:option(DummyValue, "IF")
|
||||
v:option(DummyValue, "Neighbor")
|
||||
v:option(DummyValue, "lastseen")
|
||||
|
||||
-- Basic
|
||||
s = m:section(TypedSection, "easymesh", translate("Settings"), translate("General Settings"))
|
||||
s.anonymous = true
|
||||
|
||||
---- Eanble
|
||||
o = s:option(Flag, "enabled", translate("Enable"), translate("Enable or disable EASY MESH"))
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
apRadio = s:option(ListValue, "apRadio", translate("MESH Radio device"), translate("The radio device which MESH use"))
|
||||
uci:foreach("wireless", "wifi-device",
|
||||
function(s)
|
||||
apRadio:value(s['.name'])
|
||||
end)
|
||||
o.default = "radio0"
|
||||
o.rmempty = false
|
||||
|
||||
---- mesh
|
||||
o = s:option(Value, "mesh_id", translate("MESH ID"))
|
||||
o.default = "easymesh"
|
||||
o.description = translate("MESH ID")
|
||||
|
||||
enable = s:option(Flag, "encryption", translate("Encryption"), translate(""))
|
||||
enable.default = 0
|
||||
enable.rmempty = false
|
||||
|
||||
o = s:option(Value, "key", translate("Key"))
|
||||
o.default = "easymesh"
|
||||
o:depends("encryption", 1)
|
||||
|
||||
return m
|
47
package/lean/luci-app-easymesh/po/zh-cn/easymesh.po
Executable file
47
package/lean/luci-app-easymesh/po/zh-cn/easymesh.po
Executable file
@ -0,0 +1,47 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "easymesh"
|
||||
msgstr "easymesh"
|
||||
|
||||
msgid "<b>Active node:" .. Nodes .. "</b>"
|
||||
msgstr "<b>活动节点:" .. Nodes .. "</b>"
|
||||
|
||||
msgid "IF"
|
||||
msgstr "IF"
|
||||
|
||||
msgid "Neighbor"
|
||||
msgstr "节点邻居设备"
|
||||
|
||||
msgid "lastseen"
|
||||
msgstr "上次连接延时"
|
||||
|
||||
msgid "EASY MESH"
|
||||
msgstr "简单MESH"
|
||||
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
msgid "General Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "MESH Radio device"
|
||||
msgstr "MESH无线设备"
|
||||
|
||||
msgid "The radio device which MESH use"
|
||||
msgstr "使用MESH组网的无线设备"
|
||||
|
||||
msgid "AUTO"
|
||||
msgstr "自动"
|
||||
|
||||
msgid "Enable or disable EASY MESH"
|
||||
msgstr "启用或禁用简单MESH"
|
||||
|
||||
msgid "Encryption"
|
||||
msgstr "加密"
|
||||
|
||||
msgid "Key"
|
||||
msgstr "密码"
|
1
package/lean/luci-app-easymesh/po/zh_Hans
Symbolic link
1
package/lean/luci-app-easymesh/po/zh_Hans
Symbolic link
@ -0,0 +1 @@
|
||||
zh-cn
|
3
package/lean/luci-app-easymesh/root/etc/config/easymesh
Executable file
3
package/lean/luci-app-easymesh/root/etc/config/easymesh
Executable file
@ -0,0 +1,3 @@
|
||||
|
||||
config easymesh 'config'
|
||||
option enabled '0'
|
107
package/lean/luci-app-easymesh/root/etc/init.d/easymesh
Executable file
107
package/lean/luci-app-easymesh/root/etc/init.d/easymesh
Executable file
@ -0,0 +1,107 @@
|
||||
#!/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)
|
||||
lan=$(uci get network.lan.ifname 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)
|
||||
|
||||
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 add_list network.lan.ifname='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
|
||||
|
||||
/etc/init.d/network restart
|
||||
else
|
||||
stop
|
||||
fi
|
||||
}
|
||||
|
||||
stop(){
|
||||
if [ "$enable" != 1 ]; then
|
||||
if [ "$mesh_bat0" = "interface" ]; then
|
||||
uci delete network.bat0
|
||||
uci del_list network.lan.ifname='bat0'
|
||||
uci commit 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
|
||||
fi
|
||||
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
start
|
||||
}
|
11
package/lean/luci-app-easymesh/root/etc/uci-defaults/luci-easymesh
Executable file
11
package/lean/luci-app-easymesh/root/etc/uci-defaults/luci-easymesh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@easymesh[-1]
|
||||
add ucitrack easymesh
|
||||
set ucitrack.@easymesh[-1].init=easymesh
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-easymesh": {
|
||||
"description": "Grant UCI access for luci-app-easymesh",
|
||||
"read": {
|
||||
"uci": [ "easymesh" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "easymesh" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user