mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-15 18:03:30 +00:00
luci-app-fogvdn: add fogvdn new package
This commit is contained in:
parent
fe71259e68
commit
543621f9d6
53
package/lean/fogvdn/Makefile
Normal file
53
package/lean/fogvdn/Makefile
Normal file
@ -0,0 +1,53 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/target.mk
|
||||
|
||||
PKG_NAME:=fogvdn
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
PKG_HASH:=skip
|
||||
|
||||
ifeq ($(ARCH),x86_64)
|
||||
PKG_ARCH:=X64
|
||||
else ifeq ($(ARCH),arm)
|
||||
PKG_ARCH:=ARM
|
||||
else ifeq ($(ARCH),aarch64)
|
||||
PKG_ARCH:=ARM64
|
||||
endif
|
||||
|
||||
PKG_SOURCE:=fogvdn_PEAR_$(PKG_ARCH)_LINUX_latest.tar.gz
|
||||
PKG_SOURCE_URL:=https://download.openfogos.com/release/
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
PKG_UNPACK:=$(HOST_TAR) -C $(PKG_BUILD_DIR)/root --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
|
||||
|
||||
define Package/fogvdn
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=OpenFog Pear P2P CDN
|
||||
DEPENDS:=@(aarch64||arm||x86_64) \
|
||||
+bash +getopt +jq +ntpdate +whereis \
|
||||
+smartmontools +zoneinfo-all +coreutils \
|
||||
+coreutils-install +coreutils-df +coreutils-nohup
|
||||
endef
|
||||
|
||||
define Package/fogvdn/description
|
||||
OpenFog Pear Peer-to-Peer Content Delivery Network
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)/root
|
||||
$(PKG_UNPACK)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/fogvdn/install
|
||||
$(CP) $(PKG_BUILD_DIR)/root/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,fogvdn))
|
17
package/lean/luci-app-fogvdn/Makefile
Normal file
17
package/lean/luci-app-fogvdn/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
LLUCI_TITLE:=Luci for OpenFog Pear P2P CDN
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=7
|
||||
PKG_RELEASE:=1
|
||||
LUCI_DEPENDS:=+luci-compat +fogvdn +jq +lsblk
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
30
package/lean/luci-app-fogvdn/luasrc/controller/pearpcdn.lua
Normal file
30
package/lean/luci-app-fogvdn/luasrc/controller/pearpcdn.lua
Normal file
@ -0,0 +1,30 @@
|
||||
module("luci.controller.pearpcdn", package.seeall)
|
||||
fs = require "nixio.fs"
|
||||
I18N = require "luci.i18n"
|
||||
translate = I18N.translate
|
||||
json = require "luci.jsonc"
|
||||
function index()
|
||||
entry({"admin", "pcdn"}, firstchild(), _("PCDN"), 28).dependent = true
|
||||
entry({"admin", "pcdn","pear_pcdn"}, cbi("pearpcdn/fogvdn"),_("FOGVDN"),1).dependent = true
|
||||
entry({"admin", "pcdn","pear_pcdn", "get_act_status"}, call("get_act_status"),nil).leaf = true
|
||||
end
|
||||
|
||||
function get_act_status()
|
||||
data = {}
|
||||
data["status"] = "0"
|
||||
|
||||
--pid file
|
||||
pid_file="/run/pear_restart.pid"
|
||||
--if not exist, return 0
|
||||
if fs.access(pid_file) then
|
||||
--if dir /proc/pid exist, return 1
|
||||
--trim \n
|
||||
pid = fs.readfile(pid_file)
|
||||
pid = string.gsub(pid, "\n", "")
|
||||
if fs.access("/proc/"..pid) then
|
||||
data["status"] = "1"
|
||||
end
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(data)
|
||||
end
|
@ -0,0 +1,208 @@
|
||||
uci = require "luci.model.uci".cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local json = require "luci.jsonc"
|
||||
m = Map("fogvdn", translate("FOGVDN Node"))
|
||||
s = m:section(NamedSection, "main", "main", translate("Main"))
|
||||
|
||||
act_status = s:option(DummyValue, "act_status", translate("Status"))
|
||||
act_status.template = "pcdn/act_status"
|
||||
|
||||
enabled = s:option(Flag, "enable", translate("Enable"))
|
||||
enabled.default = 0
|
||||
|
||||
node_info_file = "/etc/pear/pear_monitor/node_info.json"
|
||||
if fs.access(node_info_file) then
|
||||
local node_info = fs.readfile(node_info_file)
|
||||
node_info = json.parse(node_info)
|
||||
for k,v in pairs(node_info) do
|
||||
|
||||
node_info_file = "/etc/pear/pear_monitor/node_info.json"
|
||||
if fs.access(node_info_file) then
|
||||
local node_info = fs.readfile(node_info_file)
|
||||
node_info = json.parse(node_info)
|
||||
for k,v in pairs(node_info) do
|
||||
if k == "node_id" then
|
||||
option = s:option(DummyValue, "_"..k,translate(k))
|
||||
option.value = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
storage_info_file = "/etc/pear/pear_monitor/storage_info.json"
|
||||
if fs.access(storage_info_file) then
|
||||
local storage_info = fs.readfile(storage_info_file)
|
||||
storage_info = json.parse(storage_info)
|
||||
for k,v in pairs(storage_info) do
|
||||
if k == "os_drive_serial" then
|
||||
option = s:option(DummyValue, "_"..k,translate(k))
|
||||
option.value = v
|
||||
end
|
||||
end
|
||||
end
|
||||
option = s:option(DummyValue, "_"..k,translate(k))
|
||||
option.value = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
openfog_link=s:option(DummyValue, "openfog_link", translate("<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Openfogos.com\" onclick=\"window.open('https://openfogos.com/')\" />"))
|
||||
openfog_link.description = translate("OpenFogOS Official Website")
|
||||
|
||||
s = m:section(TypedSection, "instance", translate("Settings"))
|
||||
s.anonymous = true
|
||||
s.description = translate("Fogvdn Settings")
|
||||
|
||||
username = s:option(Value, "username", translate("username"))
|
||||
username.description = translate("<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Register\" onclick=\"window.open('https://account.openfogos.com/signup?source%3Dopenfogos.com%26')\" />")
|
||||
|
||||
region = s:option(Value, "region", translate("Region"))
|
||||
region.optional = true
|
||||
region.template="cbi/city"
|
||||
|
||||
isp = s:option(Value, "isp", translate("ISP"))
|
||||
isp.optional = true
|
||||
isp:value("电信", translate("China Telecom"))
|
||||
isp:value("移动", translate("China Mobile"))
|
||||
isp:value("联通", translate("China Unicom"))
|
||||
|
||||
per_line_up_bw = s:option(Value, "per_line_up_bw", translate("Per Line Up BW"))
|
||||
per_line_up_bw.template = "cbi/digitonlyvalue"
|
||||
per_line_up_bw.datatype = "uinteger"
|
||||
|
||||
per_line_down_bw = s:option(Value, "per_line_down_bw", translate("Per Line Down BW"))
|
||||
per_line_down_bw.template = "cbi/digitonlyvalue"
|
||||
per_line_down_bw.datatype = "uinteger"
|
||||
|
||||
limited_memory = s:option(Value, "limited_memory", translate("Limited Memory"))
|
||||
limited_memory.optional = true
|
||||
limited_memory.template = "cbi/digitonlyvalue"
|
||||
limited_memory.datatype = "range(0, 100)"
|
||||
-- 0-100%
|
||||
limited_storage = s:option(Value, "limited_storage", translate("Limited Storage"))
|
||||
limited_storage.optional = true
|
||||
limited_storage.template = "cbi/digitonlyvalue"
|
||||
limited_storage.datatype = "range(0, 100)"
|
||||
-- 0-100%
|
||||
|
||||
limited_area = s:option(Value, "limited_area", translate("Limited Area"))
|
||||
limited_area.default = "2"
|
||||
limited_area:value("-1", "不设置:若不确定运营商对流量出省的限制情况,建议选择该项")
|
||||
limited_area:value("0", "全国调度:流量将会向全国调度,出省比例较高,可能会导致运营商的限制")
|
||||
limited_area:value("1", "本省调度:流量只会向所在省份内调度,是比较安全的调度模式,但跑量可能会降低")
|
||||
limited_area:value("2", "大区调度:流量只会向所在大区内调度,出省比例较低,是安全性和跑量之间较为均衡的模式")
|
||||
-- 限制地区 -1 不设置(采用openfogos默认) 0 全国调度,1 省份调度,2 大区调度
|
||||
|
||||
nics = s:option(DynamicList,"nics",translate("netdev"))
|
||||
-- uci:foreach("multiwan","multiwan",function (instance)
|
||||
-- nics:value(instance["tag"])
|
||||
-- end
|
||||
-- )
|
||||
--list /sys/class/net, filter bridge device
|
||||
cmd="/usr/share/pcdn/check_netdev get_netdevs"
|
||||
json_dump=luci.sys.exec(cmd)
|
||||
devs=json.parse(json_dump)
|
||||
for k,v in pairs(devs) do
|
||||
nics:value(k,k.." ["..v.."]")
|
||||
end
|
||||
|
||||
storage = s:option(DynamicList, "storage", translate("Storage"))
|
||||
storage.default = "/opt/openfogos"
|
||||
storage.description = translate("Warnning: System directory is not allowed!")
|
||||
--filter start with /etc /usr /root /var /tmp /dev /proc /sys /overlay /rom and root
|
||||
mount_point = {}
|
||||
cmd="/usr/share/pcdn/check_mount_ponit mount_point"
|
||||
json_dump=luci.sys.exec(cmd)
|
||||
mount_point=json.parse(json_dump)
|
||||
for k,v in pairs(mount_point) do
|
||||
storage:value(k,k.."("..v..")")
|
||||
end
|
||||
|
||||
btn = s:option(Button, "_filter", "")
|
||||
btn.inputtitle = "应用最佳存储设置"
|
||||
btn.description = "为避免木桶效应,点击估算最佳设置"
|
||||
btn.inputstyle = "apply"
|
||||
|
||||
-- 获取表中元素的索引
|
||||
table.indexOf = function(tbl, value)
|
||||
for i, v in ipairs(tbl) do
|
||||
if v == value then return i end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
-- 拷贝表
|
||||
table.copy = function(tbl)
|
||||
local copy = {}
|
||||
for k, v in pairs(tbl) do
|
||||
copy[k] = v
|
||||
end
|
||||
return copy
|
||||
end
|
||||
|
||||
-- 解析并转换大小单位
|
||||
function parseSize(size)
|
||||
if type(size) ~= "string" then return 0 end
|
||||
|
||||
local unit = {"B", "K", "M", "G", "T"}
|
||||
|
||||
local num, u = string.match(size, "^(%d+%.?%d*)([KMGT]?)$")
|
||||
if not num then return 0 end
|
||||
|
||||
local i = table.indexOf(unit, u)
|
||||
|
||||
-- 如果没有找到单位,默认为字节
|
||||
if i == -1 then
|
||||
return tonumber(num)
|
||||
else
|
||||
return tonumber(num) * (1024 ^ i)
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取最佳存储方案
|
||||
function getOptimalSolution(numsObjArray)
|
||||
if type(numsObjArray) ~= "table" or #numsObjArray == 0 then return {} end
|
||||
|
||||
-- 拷贝并按大小排序
|
||||
local nums = {}
|
||||
for _, v in ipairs(numsObjArray) do
|
||||
table.insert(nums, {name = v.name, size = v.size})
|
||||
end
|
||||
table.sort(nums, function(a, b)
|
||||
return parseSize(a.size) < parseSize(b.size)
|
||||
end)
|
||||
|
||||
local max = 0
|
||||
local optimal = {}
|
||||
|
||||
while #nums > 0 do
|
||||
local temp = parseSize(nums[1].size) * #nums
|
||||
if temp > max then
|
||||
max = temp
|
||||
optimal = table.copy(nums)
|
||||
end
|
||||
table.remove(nums, 1) -- 移除第一个元素
|
||||
end
|
||||
|
||||
-- 提取名称并排序
|
||||
local result = {}
|
||||
for _, v in ipairs(optimal) do
|
||||
table.insert(result, v.name)
|
||||
end
|
||||
table.sort(result)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
function btn.write(self, section)
|
||||
local numsObjArray = {}
|
||||
|
||||
for k,v in pairs(mount_point) do
|
||||
table.insert(numsObjArray, {name = k, size = v})
|
||||
end
|
||||
|
||||
local optimalStorage = getOptimalSolution(numsObjArray)
|
||||
|
||||
self.map:set(section, "storage", optimalStorage)
|
||||
end
|
||||
|
||||
return m
|
5738
package/lean/luci-app-fogvdn/luasrc/view/cbi/city.htm
Normal file
5738
package/lean/luci-app-fogvdn/luasrc/view/cbi/city.htm
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
<%+cbi/valueheader%>
|
||||
<input data-update="change"<%=
|
||||
attr("id", cbid) ..
|
||||
attr("name", cbid) ..
|
||||
attr("type", self.password and "password" or "text") ..
|
||||
attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
|
||||
attr("value", self:cfgvalue(section) or self.default) ..
|
||||
ifattr(self.size, "size") ..
|
||||
ifattr(self.placeholder, "placeholder") ..
|
||||
ifattr(self.readonly, "readonly") ..
|
||||
ifattr(self.maxlength, "maxlength") ..
|
||||
ifattr(self.datatype, "data-type", self.datatype) ..
|
||||
ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
|
||||
ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
|
||||
ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
|
||||
%> />
|
||||
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
|
||||
<script>
|
||||
document.getElementById('<%=cbid%>').onkeyup = function () {
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
}
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,87 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<%-
|
||||
local utl = require "luci.util"
|
||||
local nwm = require "luci.model.network".init()
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local net, iface
|
||||
local networks = nwm:get_networks()
|
||||
local value = self:formvalue(section)
|
||||
|
||||
self.cast = nil
|
||||
|
||||
if not value or value == "-" then
|
||||
value = self:cfgvalue(section) or self.default
|
||||
end
|
||||
|
||||
local checked = { }
|
||||
for value in utl.imatch(value) do
|
||||
checked[value] = true
|
||||
end
|
||||
|
||||
-%>
|
||||
|
||||
<ul style="margin:0; list-style-type:none; text-align:left">
|
||||
<% for _, net in ipairs(networks) do
|
||||
if (net:name() ~= "loopback") and
|
||||
(net:name() ~= self.exclude) and
|
||||
(net:name() ~= "lan") and
|
||||
(not self.novirtual or not net:is_virtual())
|
||||
then %>
|
||||
<li style="padding:0.25em 0">
|
||||
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=
|
||||
attr("type", self.widget or "radio") ..
|
||||
attr("id", cbid .. "." .. net:name()) ..
|
||||
attr("name", cbid) .. attr("value", net:name()) ..
|
||||
ifattr(checked[net:name()], "checked", "checked")
|
||||
%> />  
|
||||
<label<%=attr("for", cbid .. "." .. net:name())%>>
|
||||
<span class="ifacebadge"><%=net:name()%>:
|
||||
<%
|
||||
local empty = true
|
||||
for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
|
||||
if not iface:is_bridge() then
|
||||
empty = false
|
||||
%>
|
||||
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
|
||||
<% end end %>
|
||||
<% if empty then %><em><%:(no interfaces attached)%></em><% end %>
|
||||
</span>
|
||||
</label>
|
||||
</li>
|
||||
<% end end %>
|
||||
|
||||
<% if not self.nocreate then %>
|
||||
<li style="padding:0.25em 0">
|
||||
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value and self.widget ~= "checkbox", "checked", "checked")%> />  
|
||||
<%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%>
|
||||
<label<%=attr("for", cbid .. "_new")%>></label>
|
||||
<%- end -%>
|
||||
<div style="padding:0.5em; display:inline">
|
||||
<label<%=attr("for", cbid .. "_new")%>><em>
|
||||
<%- if self.widget == "checkbox" then -%>
|
||||
<%:create:%>
|
||||
<%- else -%>
|
||||
<%:unspecified -or- create:%>
|
||||
<%- end -%> </em></label>
|
||||
<input style="display:none" type="password" />
|
||||
<input style="width:6em" type="text"<%=attr("name", cbid .. ".newnet")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
|
||||
</div>
|
||||
</li>
|
||||
<% elseif self.widget ~= "checkbox" and self.unspecified then %>
|
||||
<li style="padding:0.25em 0">
|
||||
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=
|
||||
attr("type", self.widget or "radio") ..
|
||||
attr("id", cbid .. "_uns") ..
|
||||
attr("name", cbid) ..
|
||||
attr("value", "") ..
|
||||
ifattr(not value or #value == 0, "checked", "checked")
|
||||
%> />  
|
||||
<div style="padding:0.5em; display:inline">
|
||||
<label<%=attr("for", cbid .. "_uns")%>><em><%:unspecified%></em></label>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<%+cbi/valuefooter%>
|
27
package/lean/luci-app-fogvdn/luasrc/view/pcdn/act_status.htm
Normal file
27
package/lean/luci-app-fogvdn/luasrc/view/pcdn/act_status.htm
Normal file
@ -0,0 +1,27 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<span id="<%=cbid%>"><%:Please Wait%></span>
|
||||
<script>
|
||||
XHR.poll(3,'<%=luci.dispatcher.build_url("admin","pcdn","pear_pcdn","get_act_status")%>',null,
|
||||
(x,data)=>{
|
||||
var status = data.status;
|
||||
if (status == 0){
|
||||
document.getElementById('<%=cbid%>').innerHTML = "<%:Not Running%>";
|
||||
//set color to red
|
||||
document.getElementById('<%=cbid%>').style.color = "red";
|
||||
}
|
||||
else if (status == 1){
|
||||
document.getElementById('<%=cbid%>').innerHTML = "<%:Running%>";
|
||||
//set color to green
|
||||
document.getElementById('<%=cbid%>').style.color = "green";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById('<%=cbid%>').innerHTML = "<%:Please Wait%>";
|
||||
//set color to yellow
|
||||
document.getElementById('<%=cbid%>').style.color = "yellow";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<%+cbi/valuefooter%>
|
77
package/lean/luci-app-fogvdn/po/zh-Hans/fogvdn.po
Normal file
77
package/lean/luci-app-fogvdn/po/zh-Hans/fogvdn.po
Normal file
@ -0,0 +1,77 @@
|
||||
msgid "FOGVDN"
|
||||
msgstr "OpenFog"
|
||||
|
||||
msgid "FOGVDN Node"
|
||||
msgstr "OpenFog 节点"
|
||||
|
||||
msgid "OpenFogOS"
|
||||
msgstr "OpenFogOS"
|
||||
|
||||
msgid "Main"
|
||||
msgstr "主设置"
|
||||
|
||||
msgid "Fogvdn Settings"
|
||||
msgstr "OpenFog 设置"
|
||||
|
||||
msgid "username"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Region"
|
||||
msgstr "地区"
|
||||
|
||||
msgid "ISP"
|
||||
msgstr "运营商"
|
||||
|
||||
msgid "Per Line Up BW"
|
||||
msgstr "每条线路上行带宽(Mbps)"
|
||||
|
||||
msgid "Per Line Down BW"
|
||||
msgstr "每条线路下行带宽(Mbps)"
|
||||
|
||||
msgid "Limited Memory"
|
||||
msgstr "内存限制(%)"
|
||||
|
||||
msgid "Limited Storage"
|
||||
msgstr "存储限制(%)"
|
||||
|
||||
msgid "Limited Area"
|
||||
msgstr "地区限制"
|
||||
|
||||
msgid "netdev"
|
||||
msgstr "网络设备"
|
||||
|
||||
msgid "Storage"
|
||||
msgstr "存储"
|
||||
|
||||
msgid "Warnning: System directory is not allowed! "
|
||||
msgstr "警告: 系统目录不允许使用! "
|
||||
|
||||
msgid "Please Wait"
|
||||
msgstr "请稍等"
|
||||
|
||||
msgid "Running"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Not Running"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Openfogos.com\" onclick=\"window.open('https://openfogos.com/')\" />"
|
||||
msgstr "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Openfogos官网\" onclick=\"window.open('https://openfogos.com/')\" />"
|
||||
|
||||
msgid "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Register\" onclick=\"window.open('https://account.openfogos.com/signup?source%3Dopenfogos.com%26')\" />"
|
||||
msgstr "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"前往注册\" onclick=\"window.open('https://account.openfogos.com/signup?source%3Dopenfogos.com%26')\" />"
|
||||
|
||||
msgid "China Telecom"
|
||||
msgstr "中国电信"
|
||||
|
||||
msgid "China Unicom"
|
||||
msgstr "中国联通"
|
||||
|
||||
msgid "China Mobile"
|
||||
msgstr "中国移动"
|
||||
|
||||
msgid "OpenFogOS Official Website"
|
||||
msgstr "OpenFogOS 官网"
|
||||
|
||||
msgid "Warnning: System directory is not allowed!"
|
||||
msgstr "警告: 请勿使用系统目录! "
|
77
package/lean/luci-app-fogvdn/po/zh-cn/fogvdn.po
Normal file
77
package/lean/luci-app-fogvdn/po/zh-cn/fogvdn.po
Normal file
@ -0,0 +1,77 @@
|
||||
msgid "FOGVDN"
|
||||
msgstr "OpenFog"
|
||||
|
||||
msgid "FOGVDN Node"
|
||||
msgstr "OpenFog 节点"
|
||||
|
||||
msgid "OpenFogOS"
|
||||
msgstr "OpenFogOS"
|
||||
|
||||
msgid "Main"
|
||||
msgstr "主设置"
|
||||
|
||||
msgid "Fogvdn Settings"
|
||||
msgstr "OpenFog 设置"
|
||||
|
||||
msgid "username"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Region"
|
||||
msgstr "地区"
|
||||
|
||||
msgid "ISP"
|
||||
msgstr "运营商"
|
||||
|
||||
msgid "Per Line Up BW"
|
||||
msgstr "每条线路上行带宽(Mbps)"
|
||||
|
||||
msgid "Per Line Down BW"
|
||||
msgstr "每条线路下行带宽(Mbps)"
|
||||
|
||||
msgid "Limited Memory"
|
||||
msgstr "内存限制(%)"
|
||||
|
||||
msgid "Limited Storage"
|
||||
msgstr "存储限制(%)"
|
||||
|
||||
msgid "Limited Area"
|
||||
msgstr "地区限制"
|
||||
|
||||
msgid "netdev"
|
||||
msgstr "网络设备"
|
||||
|
||||
msgid "Storage"
|
||||
msgstr "存储"
|
||||
|
||||
msgid "Warnning: System directory is not allowed! "
|
||||
msgstr "警告: 系统目录不允许使用! "
|
||||
|
||||
msgid "Please Wait"
|
||||
msgstr "请稍等"
|
||||
|
||||
msgid "Running"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Not Running"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Openfogos.com\" onclick=\"window.open('https://openfogos.com/')\" />"
|
||||
msgstr "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Openfogos官网\" onclick=\"window.open('https://openfogos.com/')\" />"
|
||||
|
||||
msgid "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Register\" onclick=\"window.open('https://account.openfogos.com/signup?source%3Dopenfogos.com%26')\" />"
|
||||
msgstr "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"前往注册\" onclick=\"window.open('https://account.openfogos.com/signup?source%3Dopenfogos.com%26')\" />"
|
||||
|
||||
msgid "China Telecom"
|
||||
msgstr "中国电信"
|
||||
|
||||
msgid "China Unicom"
|
||||
msgstr "中国联通"
|
||||
|
||||
msgid "China Mobile"
|
||||
msgstr "中国移动"
|
||||
|
||||
msgid "OpenFogOS Official Website"
|
||||
msgstr "OpenFogOS 官网"
|
||||
|
||||
msgid "Warnning: System directory is not allowed!"
|
||||
msgstr "警告: 请勿使用系统目录! "
|
5
package/lean/luci-app-fogvdn/root/etc/config/fogvdn
Normal file
5
package/lean/luci-app-fogvdn/root/etc/config/fogvdn
Normal file
@ -0,0 +1,5 @@
|
||||
config main 'main'
|
||||
option enable '0'
|
||||
|
||||
config instance
|
||||
list storage '/opt/openfogos'
|
136
package/lean/luci-app-fogvdn/root/etc/init.d/fogvdn
Executable file
136
package/lean/luci-app-fogvdn/root/etc/init.d/fogvdn
Executable file
@ -0,0 +1,136 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
STOP=1
|
||||
|
||||
CONFIG_PATH=/etc/pear/pear_monitor
|
||||
target_config_path=${CONFIG_PATH}/config.json
|
||||
|
||||
|
||||
function run_instance()
|
||||
{
|
||||
if [ -f $target_config_path ];then
|
||||
user_marked=$(cat $target_config_path |jq .user_marked)
|
||||
if [ -n "$user_marked" ] && [ "$user_marked" != "null" ];then
|
||||
json="$(cat $target_config_path)"
|
||||
else
|
||||
json="{}"
|
||||
fi
|
||||
else
|
||||
json="{}"
|
||||
fi
|
||||
|
||||
config_get username $1 username
|
||||
config_get isp $1 isp
|
||||
config_get region $1 region
|
||||
config_get per_line_up_bw $1 per_line_up_bw null
|
||||
config_get per_line_down_bw $1 per_line_down_bw null
|
||||
config_get limited_memory $1 limited_memory null
|
||||
config_get limited_storage $1 limited_storage null
|
||||
config_get limited_area $1 limited_area null
|
||||
country="中国"
|
||||
province=$(echo $region | awk -F'-' '{print $1}')
|
||||
city=$(echo $region | awk -F'-' '{print $2}')
|
||||
mtime=$(date +%s)
|
||||
json=$(echo "$json" | jq --arg username "$username" \
|
||||
--arg isp "$isp" \
|
||||
--arg country "$country" \
|
||||
--arg province "$province" \
|
||||
--arg city "$city" \
|
||||
--argjson per_line_up_bw "$per_line_up_bw" \
|
||||
--argjson per_line_down_bw "$per_line_down_bw" \
|
||||
--argjson limited_memory "$limited_memory" \
|
||||
--argjson limited_storage "$limited_storage" \
|
||||
--argjson limited_area "$limited_area" \
|
||||
--argjson mtime "$mtime" \
|
||||
'.user_marked.username = $username |
|
||||
.user_marked.isp = $isp |
|
||||
.user_marked.country = $country |
|
||||
.user_marked.province = $province |
|
||||
.user_marked.city = $city |
|
||||
.user_marked.per_line_up_bw = $per_line_up_bw |
|
||||
.user_marked.per_line_down_bw = $per_line_down_bw |
|
||||
.user_marked.limited_memory = $limited_memory |
|
||||
.user_marked.limited_storage = $limited_storage |
|
||||
.user_marked.limited_area = $limited_area |
|
||||
.user_marked.mtime = $mtime |
|
||||
del(.user_marked[] | select(. == null))'
|
||||
)
|
||||
json=$(echo "$json" | jq '.storage = []')
|
||||
json=$(echo "$json" | jq '.nics = []')
|
||||
config_list_foreach $1 storage storage_hd
|
||||
config_list_foreach $1 nics nics_hd
|
||||
# Save modified JSON back to target_config_path
|
||||
echo "$json" > $target_config_path
|
||||
instance=$1
|
||||
/etc/init.d/openfog.sh stop
|
||||
procd_open_instance ${instance}_check_alive
|
||||
procd_set_param command "/usr/share/pcdn/check_alive.sh"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
function storage_hd()
|
||||
{
|
||||
json=$(echo "$json" | jq --arg item "$1" '.storage += [$item]')
|
||||
[ ! -d "$1" ] && mkdir -p $1
|
||||
}
|
||||
|
||||
function nics_hd()
|
||||
{
|
||||
# config=$1
|
||||
# # check if vw$config exists
|
||||
# config_1=$(uci get network.vw$config)
|
||||
# # check if $config exists
|
||||
# config_2=$(uci get network.$config)
|
||||
# if [ -z "$config_1" ] && [ -z "$config_2" ];then
|
||||
# res=$(echo $json | jq '.nics | index(["'${config}'"])')
|
||||
# [ "$res" == "null" ] && json=$(echo "$json" | jq --arg item "$config" '.nics += [$item]')
|
||||
# return
|
||||
# fi
|
||||
# if [ "$config_1" != "interface" ];then
|
||||
# config=$config
|
||||
# else
|
||||
# config=vw$config
|
||||
# fi
|
||||
# l2_device=$(uci get network.$config.ifname)
|
||||
# proto=$(uci get network.$config.proto)
|
||||
# if [ "$proto" == "pppoe" ];then
|
||||
# nic_name=pppoe-$config
|
||||
# else
|
||||
# nic_name=$l2_device
|
||||
# fi
|
||||
nic_name=$1
|
||||
res=$(echo $json | jq '.nics | index(["'${nic_name}'"])')
|
||||
[ "$res" == "null" ] && json=$(echo "$json" | jq --arg item "$nic_name" '.nics += [$item]')
|
||||
}
|
||||
|
||||
function stop_instance()
|
||||
{
|
||||
instance=$1
|
||||
service_stop ${instance}_check_alive
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
config_load fogvdn
|
||||
config_get enable main enable
|
||||
[ "$enable" == "1" ] && config_foreach run_instance instance || stop
|
||||
}
|
||||
|
||||
stop_service()
|
||||
{
|
||||
config_foreach stop_instance instance
|
||||
/etc/init.d/openfog.sh stop
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "fogvdn"
|
||||
}
|
||||
|
||||
reload_servie()
|
||||
{
|
||||
stop
|
||||
start
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
mkdir /run
|
||||
/etc/pear/pear_update/post_command.sh
|
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
rm -f /tmp/luci-indexcache
|
||||
#uci track
|
||||
cfg_id=$(uci add ucitrack fogvdn)
|
||||
uci set ucitrack.$cfg_id.init="fogvdn"
|
||||
uci commit ucitrack
|
||||
exit 0
|
17
package/lean/luci-app-fogvdn/root/usr/share/pcdn/check_alive.sh
Executable file
17
package/lean/luci-app-fogvdn/root/usr/share/pcdn/check_alive.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
pid_file="/run/pear_restart.pid"
|
||||
while true; do
|
||||
if [ -f $pid_file ]; then
|
||||
pid=$(cat $pid_file)
|
||||
if [ -n "$pid" ]; then
|
||||
if [ ! -d /proc/$pid ]; then
|
||||
logger -t "fogvdn" "fogvdn is not running, restart it"
|
||||
/etc/init.d/openfog.sh start
|
||||
fi
|
||||
fi
|
||||
else
|
||||
logger -t "fogvdn" "pid file not found, restart it"
|
||||
/etc/init.d/openfog.sh start
|
||||
fi
|
||||
sleep 10
|
||||
done
|
57
package/lean/luci-app-fogvdn/root/usr/share/pcdn/check_mount_ponit
Executable file
57
package/lean/luci-app-fogvdn/root/usr/share/pcdn/check_mount_ponit
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# 脚本功能:json方式返回 大于某个容量的磁盘挂载点及其大小
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
get_disk_info() {
|
||||
disk_info=$(lsblk |grep disk)
|
||||
IFS=$'\n'
|
||||
for disk in `echo -e "$disk_info"`; do
|
||||
disk_name=$(echo $disk |awk '{print $1}')
|
||||
disk_capacity=$(echo $disk |awk '{print $4}')
|
||||
json_add_string "$disk_name" "$disk_capacity"
|
||||
done
|
||||
}
|
||||
|
||||
get_part_info() {
|
||||
part_info=$(lsblk |grep part)
|
||||
IFS=$'\n'
|
||||
for part in `echo -e "$part_info"`; do
|
||||
part_name=$(echo $part |awk '{print $1}')
|
||||
part_capacity=$(echo $part |awk '{print $4}')
|
||||
json_add_string "$part_name" "$part_capacity"
|
||||
done
|
||||
}
|
||||
|
||||
get_mount_point_info() {
|
||||
mount_point_info=$(lsblk -o SIZE,MOUNTPOINT |grep -v MOUNTPOINT)
|
||||
#filter /rom /overlay [SWAP]
|
||||
mount_point_info=$(echo -e "$mount_point_info" |grep -v -E "/rom|/overlay|\[SWAP\]")
|
||||
#filter capacity that unit is M or K
|
||||
mount_point_info=$(echo -e "$mount_point_info" |grep -v -E "M|K")
|
||||
|
||||
IFS=$'\n'
|
||||
#filter start with /mnt
|
||||
for mount_point in `echo -e "$mount_point_info"`; do
|
||||
mount_point_name=$(echo $mount_point |awk '{print $2}')
|
||||
mount_point_capacity=$(echo $mount_point |awk '{print $1}')
|
||||
if [ -z "$mount_point_capacity" ] || [ -z "$mount_point_name" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
json_add_string "$mount_point_name/openfogos" "$mount_point_capacity"
|
||||
done
|
||||
}
|
||||
|
||||
json_init
|
||||
case $1 in
|
||||
disk)
|
||||
get_disk_info
|
||||
;;
|
||||
part)
|
||||
get_part_info
|
||||
;;
|
||||
mount_point)
|
||||
get_mount_point_info
|
||||
;;
|
||||
esac
|
||||
json_dump
|
37
package/lean/luci-app-fogvdn/root/usr/share/pcdn/check_netdev
Executable file
37
package/lean/luci-app-fogvdn/root/usr/share/pcdn/check_netdev
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# 脚本功能:json方式返回 网络物理设备
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
function get_netdevs()
|
||||
{
|
||||
# 过滤条件:无ip, bridge, wlan, lo 设备
|
||||
for netdev in `ls /sys/class/net`;do
|
||||
if [ -d "/sys/class/net/$netdev" ] && [ -n "$netdev" ];then
|
||||
filter=0
|
||||
unset DEVTYPE
|
||||
. /sys/class/net/$netdev/uevent
|
||||
cdir4=`ip addr show dev $netdev|grep "inet " | grep -E -o '([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}' | sed ':a;N;$!ba;s/\n/;/g'`
|
||||
|
||||
[ -z "$cdir4" ] && filter=1
|
||||
[ "$DEVTYPE" == "bridge" ] && filter=1
|
||||
[ "$DEVTYPE" == "wlan" ] && filter=1
|
||||
[ "$netdev" == "lo" ] && filter=1
|
||||
if [ "$filter" -eq 0 ];then
|
||||
macaddr=`cat /sys/class/net/$netdev/address`
|
||||
#format $netdev (ip:cdir4 mac:address)
|
||||
netdev_info="IP: $cdir4;"
|
||||
[ -n "$macaddr" ] && netdev_info="$netdev_info MAC:$macaddr"
|
||||
[ -n "$DEVTYPE" ] && netdev_info="$netdev_info TYPE:$DEVTYPE"
|
||||
json_add_string $netdev "$netdev_info"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
json_init
|
||||
case $1 in
|
||||
get_netdevs)
|
||||
get_netdevs
|
||||
;;
|
||||
esac
|
||||
json_dump
|
@ -0,0 +1,17 @@
|
||||
{
|
||||
"luci-app-fogvdn": {
|
||||
"description": "Grant UCI access for luci-app-fogvdn",
|
||||
"read": {
|
||||
"file": {
|
||||
"/etc/pear/pear_monitor/*": [ "read" ]
|
||||
},
|
||||
"uci": ["fogvdn"]
|
||||
},
|
||||
"write": {
|
||||
"file": {
|
||||
"/etc/pear/pear_monitor/*": [ "write" ]
|
||||
},
|
||||
"uci": ["fogvdn"]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user