update 2025-06-25 11:17:21

This commit is contained in:
kenzok8
2025-06-25 11:17:21 +08:00
parent a18be6b66f
commit 6263cb7232
24 changed files with 278 additions and 369 deletions

View File

@@ -1,7 +0,0 @@
module("luci.controller.bmtedge", package.seeall)
function index()
entry({"admin", "services", "bmtedge"}, alias("admin", "services", "bmtedge", "config"), _("BlueMountain Edge"), 30).dependent = true
entry({"admin", "services", "bmtedge", "config"}, cbi("bmtedge"))
end

View File

@@ -1,60 +0,0 @@
local util = require "luci.util"
local jsonc = require "luci.jsonc"
local nixio = require "nixio"
local bmtedge = {}
bmtedge.blocks = function()
local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r")
local vals = {}
if f then
local ret = f:read("*all")
f:close()
local obj = jsonc.parse(ret)
for _, val in pairs(obj["blockdevices"]) do
local fsize = val["fssize"]
if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then
-- fsize > 1G
vals[#vals+1] = val["mountpoint"]
end
end
end
return vals
end
bmtedge.default_image = function()
local dockeramd64 = "registry.cn-shanghai.aliyuncs.com/nsp-prod-1/public1:lsy-iaas-amd64-latest"
local dockerarm64 = "registry.cn-shanghai.aliyuncs.com/nsp-prod-1/public1:lsy-iaas-arm64-latest"
if string.find(nixio.uname().machine, "x86_64") then
return dockeramd64
else
return dockerarm64
end
end
local random_str = function(t)
math.randomseed(os.time())
local s = "0123456789abcdefghijklmnopqrstuvwsyz"
local value = ""
for x = 1,t do
local rand = math.random(#s)
value = value .. string.sub(s, rand, rand)
end
return value
end
bmtedge.default_uid = function()
local f = io.open("/sys/class/net/eth0/address", "r")
if not f then
f = io.open("/sys/class/net/br-lan/address", "r")
end
if not f then
return random_str(16)
end
local ret = f:read("*all")
f:close()
return string.gsub(ret, "[ \r\n:]+", "") .. random_str(8)
end
return bmtedge

View File

@@ -1,50 +0,0 @@
--[[
LuCI - Lua Configuration Interface
]]--
local taskd = require "luci.model.tasks"
local bmtedge_model = require "luci.model.bmtedge"
local m, s, o
m = taskd.docker_map("bmtedge", "bmtedge", "/usr/libexec/istorec/bmtedge.sh",
translate("BlueMountain Edge"),
"蓝山云-流量宝由蓝山联合金山云推出的一款镜像软件,通过简单安装后可快速加入蓝山的边缘计算生态,在线共享带宽即可赚钱,每月可获取一定的现金回报!了解更多,请登录「<a href=\"https://www.bmtcloud.com.cn\" target=\"_blank\" >蓝山云官网</a>」并查看<a href=\"https://doc.linkease.com/zh/guide/istoreos/software/bmtedge.html\" target=\"_blank\">「教程」</a>")
s = m:section(SimpleSection, translate("Service Status"), translate("BlueMountain Edge status:"), "注意网心云会以超级权限运行!")
s:append(Template("bmtedge/status"))
s = m:section(TypedSection, "bmtedge", translate("Setup"), translate("The following parameters will only take effect during installation or upgrade:"))
s.addremove=false
s.anonymous=true
local default_image = bmtedge_model.default_image()
o = s:option(Value, "image_name", translate("Image").."<b>*</b>")
o.rmempty = false
o.datatype = "string"
local dockeramd64 = "registry.cn-shanghai.aliyuncs.com/nsp-prod-1/public1:lsy-iaas-amd64-latest"
local dockerarm64 = "registry.cn-shanghai.aliyuncs.com/nsp-prod-1/public1:lsy-iaas-arm64-latest"
o:value(dockeramd64, dockeramd64)
o:value(dockerarm64, dockerarm64)
o.default = default_image
local default_uid = bmtedge_model.default_uid()
o = s:option(Value, "uid", translate("UID").."<b>*</b>")
o.rmempty = false
o.datatype = "string"
o:value(default_uid, default_uid)
o.default = default_uid
local blks = bmtedge_model.blocks()
local dir
o = s:option(Value, "cache_path", translate("Cache path").."<b>*</b>", "请选择合适的存储位置进行安装,安装位置容量越大,收益越高。安装后请勿轻易改动")
o.rmempty = false
o.datatype = "string"
for _, dir in pairs(blks) do
dir = dir .. "/bmtedge1"
o:value(dir, dir)
end
if #blks > 0 then
o.default = blks[1] .. "/bmtedge1"
end
return m

View File

@@ -1,73 +0,0 @@
<%
local util = require "luci.util"
local container_status = util.trim(util.exec("/usr/libexec/istorec/bmtedge.sh status"))
local container_install = (string.len(container_status) > 0)
local container_running = container_status == "running"
local uci = require "luci.model.uci".cursor()
local uid = uci:get_first("bmtedge", "bmtedge", "uid", "")
-%>
<div class="cbi-value">
<label class="cbi-value-title"><%:Status%></label>
<div class="cbi-value-field">
<% if container_running then %>
<button class="cbi-button cbi-button-success" id="btnShowQr"><%:Running, click to show QR%></button>
<% else %>
<button class="cbi-button cbi-button-negative" disabled="true"><%:BlueMountain Edge is not running%></button>
<% end %>
</div>
</div>
<div class="cbi-value" id="winContainer" style="display: none">
<label class="cbi-value-title"></label>
<div class="cbi-value-field">
<div style="display: flex;flex-direction: column;align-items: center; width:276px; background-color: white;">
<div style="
width: 256px;
height: 256px;
margin: 10px;
">
<div id="qrimage" >
</div>
<div id="weapp" style="display: none">
<img src="/luci-static/bmtedge/weapp.jpg" alt="小程序码" style="
width: 256px;
height: 256px;
">
</div>
</div>
<h6><a id="btnShowWeapp" href="javascript:void(0);">“蓝山云”小程序</a>扫码,请查看:<a href="https://doc.linkease.com/zh/guide/istoreos/software/bmtedge.html" target="_blank">教程</a></h6>
</div>
</div>
</div>
<script src="/luci-static/bmtedge/qrcode.min.js"></script>
<script>
(function() {
'use strict';
var shown = false;
var tryShowQr = function() {
if (shown) {
return;
}
shown = true;
new QRCode(document.getElementById("qrimage"), "lsyK18000_"+"<%=uid%>");
document.getElementById("winContainer").style.removeProperty('display');
};
document.getElementById("btnShowQr").addEventListener("click", function(e){
e.preventDefault();
tryShowQr();
});
document.getElementById("btnShowWeapp").addEventListener("mouseenter", function(e){
e.preventDefault();
document.getElementById("qrimage").style.display='none';
document.getElementById("weapp").style.removeProperty('display');
});
document.getElementById("btnShowWeapp").addEventListener("mouseleave", function(e){
e.preventDefault();
document.getElementById("weapp").style.display='none';
document.getElementById("qrimage").style.removeProperty('display');
});
})();
</script>

View File

@@ -1,40 +0,0 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "BlueMountain Edge"
msgstr "蓝山云-流量宝"
msgid "Cache path"
msgstr "缓存文件路径"
msgid "Service Status"
msgstr "服务状态"
msgid "BlueMountain Edge status:"
msgstr "蓝山云的状态信息如下:"
msgid "Setup"
msgstr "安装配置"
msgid "The following parameters will only take effect during installation or upgrade:"
msgstr "以下参数只在安装或者升级时才会生效:"
msgid "Status"
msgstr "状态"
msgid "Running, click to show QR"
msgstr "运行中,点击查看二维码"
msgid "BlueMountain Edge is not running"
msgstr "蓝山云未运行"
msgid "Use “蓝山云” Wechat Little APP to scan the QR, click:"
msgstr "用“蓝山云”小程序扫码,请查看:"
msgid "Guide"
msgstr "教程"
msgid "UID"
msgstr "唯一标识"

View File

@@ -1,4 +0,0 @@
config bmtedge
# option cache_path ''
# option image_name ''
# option uid ''

View File

@@ -1,14 +0,0 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete firewall.bmtedge
set firewall.bmtedge=rule
set firewall.bmtedge.name="bmtedge"
set firewall.bmtedge.target="ACCEPT"
set firewall.bmtedge.src="wan"
set firewall.bmtedge.dest_port="1024-65535"
set firewall.bmtedge.enabled="0"
commit firewall
EOF
exit 0

View File

@@ -1,101 +0,0 @@
#!/bin/sh
ACTION=${1}
shift 1
do_install() {
local path=`uci get bmtedge.@bmtedge[0].cache_path 2>/dev/null`
local uid=`uci get bmtedge.@bmtedge[0].uid 2>/dev/null`
local image_name=`uci get bmtedge.@bmtedge[0].image_name 2>/dev/null`
if [ -z "$path" ]; then
echo "path is empty!"
exit 1
fi
local netdev=`ip route list|awk ' /^default/ {print $5}'`
if [ -z "$netdev" ]; then
echo "defualt gateway is empty!"
exit 1
fi
[ -z "$image_name" ] && image_name="jinshanyun/jinshan-x86_64:latest"
echo "docker pull ${image_name}"
docker pull ${image_name}
docker rm -f bmtedge
local cmd="docker run --restart=unless-stopped -d \
--init \
--privileged \
--network=host \
--dns=127.0.0.1 \
--dns=223.5.5.5 \
-v \"$path:/data/lsy_cloud\" \
-e ksc_datadir=\"/data/lsy_cloud\" \
-e ksc_net=\"$netdev\" \
-e ksc_machine_code=\"lsyK18000_$uid\" "
local tz="`uci get system.@system[0].zonename | sed 's/ /_/g'`"
[ -z "$tz" ] || cmd="$cmd -e TZ=$tz"
cmd="$cmd --name bmtedge \"$image_name\""
echo "$cmd"
eval "$cmd"
if [ "$?" = "0" ]; then
if [ "`uci -q get firewall.bmtedge.enabled`" = 0 ]; then
uci -q batch <<-EOF >/dev/null
set firewall.bmtedge.enabled="1"
commit firewall
EOF
/etc/init.d/firewall reload
fi
fi
echo "Install OK!"
}
usage() {
echo "usage: $0 sub-command"
echo "where sub-command is one of:"
echo " install Install the bmtedge"
echo " upgrade Upgrade the bmtedge"
echo " rm/start/stop/restart Remove/Start/Stop/Restart the bmtedge"
echo " status Onething Edge status"
echo " port Onething Edge port"
}
case ${ACTION} in
"install")
do_install
;;
"upgrade")
do_install
;;
"rm")
docker rm -f bmtedge
if [ "`uci -q get firewall.bmtedge.enabled`" = 1 ]; then
uci -q batch <<-EOF >/dev/null
set firewall.bmtedge.enabled="0"
commit firewall
EOF
/etc/init.d/firewall reload
fi
;;
"start" | "stop" | "restart")
docker ${ACTION} bmtedge
;;
"status")
docker ps --all -f 'name=^/bmtedge$' --format '{{.State}}'
;;
"port")
docker ps --all -f 'name=^/bmtedge$' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
;;
*)
usage
exit 1
;;
esac

View File

@@ -1,11 +0,0 @@
{
"luci-app-bmtedge": {
"description": "Grant UCI access for luci-app-bmtedge",
"read": {
"uci": [ "bmtedge" ]
},
"write": {
"uci": [ "bmtedge" ]
}
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -2,22 +2,22 @@
include $(TOPDIR)/rules.mk
PKG_VERSION:=1.0.2-20241211
PKG_VERSION:=1.1.9-20250625
PKG_RELEASE:=
LUCI_TITLE:=LuCI support for bmtedge
LUCI_TITLE:=LuCI support for demon
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+lsblk +docker +dockerd +luci-lib-taskd
define Package/luci-app-bmtedge/conffiles
/etc/config/bmtedge
define Package/luci-app-demon/conffiles
/etc/config/demon
endef
# prerm
# postrm
define Package/luci-app-bmtedge/prerm
define Package/luci-app-demon/prerm
#!/bin/sh
/root/usr/libexec/istorec/bmtedge.sh rm
docker rm -f demon
exit 0
endef

View File

@@ -0,0 +1,7 @@
module("luci.controller.demon", package.seeall)
function index()
entry({"admin", "services", "demon"}, alias("admin", "services", "demon", "config"), _("Onething Demon"), 30).dependent = true
entry({"admin", "services", "demon", "config"}, cbi("demon"))
end

View File

@@ -0,0 +1,43 @@
--[[
LuCI - Lua Configuration Interface
]]--
local taskd = require "luci.model.tasks"
local demon_model = require "luci.model.demon"
local m, s, o
m = taskd.docker_map("demon", "demon", "/usr/libexec/istorec/demon.sh",
translate("Onething Demon"),
"【魔王现世】为 iStoreOS 特制收益更高。每月至高可赚「千元」现在上线秒领「30天20%收益加成」,挂机托管自动赚米,拿到手软!点击查看 <a href=\"https://help.onethingcloud.com/caa9/a0fe/48b5\" target=\"_blank\">「教程」</a>")
s = m:section(SimpleSection, translate("Service Status"), translate("Onething Demon status:"), "注意容器魔王会以超级权限运行!")
s:append(Template("demon/status"))
s = m:section(TypedSection, "demon", translate("Setup"), translate("The following parameters will only take effect during installation or upgrade:"))
s.addremove=false
s.anonymous=true
o = s:option(Value, "port", translate("Port").."<b>*</b>")
o.default = "18888"
o.datatype = "port"
o = s:option(Value, "image_name", translate("Image").."<b>*</b>")
o.rmempty = false
o.datatype = "string"
o:value("images-cluster.xycloud.com/wxedge/amd64-wxedge:3.5.1-CTWXKS1748570956", "images-cluster.xycloud.com/wxedge/amd64-wxedge:3.5.1-CTWXKS1748570956")
o.default = "images-cluster.xycloud.com/wxedge/amd64-wxedge:3.5.1-CTWXKS1748570956"
local blks = demon_model.caches()
local dir
o = s:option(Value, "cache_path", translate("Cache path").."<b>*</b>", "请选择合适的存储位置进行安装,安装位置容量越大,收益越高。安装后请勿轻易改动")
o.rmempty = false
o.datatype = "string"
for _, dir in pairs(blks) do
dir = dir
o:value(dir, dir)
end
if #blks > 0 then
o.default = blks[1]
end
return m

View File

@@ -0,0 +1,31 @@
local util = require "luci.util"
local jsonc = require "luci.jsonc"
local nixio = require "nixio"
local uci = luci.model.uci.cursor()
local demon = {}
demon.caches = function()
local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r")
local vals = {}
local old_cache = uci:get("wxedge", "@wxedge[0]", "cache_path") or ""
if old_cache ~= nil and string.len(old_cache) > 0 then
vals[#vals+1] = old_cache
end
if f then
local ret = f:read("*all")
f:close()
local obj = jsonc.parse(ret)
for _, val in pairs(obj["blockdevices"]) do
local fsize = val["fssize"]
if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] and val["mountpoint"] ~= old_cache then
-- fsize > 1G
vals[#vals+1] = val["mountpoint"] .. "/demon_cache"
end
end
end
return vals
end
return demon

View File

@@ -0,0 +1,31 @@
<%
local util = require "luci.util"
local container_status = util.trim(util.exec("/usr/libexec/istorec/demon.sh status"))
local container_install = (string.len(container_status) > 0)
local container_running = container_status == "running"
-%>
<div class="cbi-value">
<label class="cbi-value-title"><%:Status%></label>
<div class="cbi-value-field">
<% if container_running then %>
<button class="cbi-button cbi-button-success" disabled="true"><%:Onething Demon is running%></button>
<% else %>
<button class="cbi-button cbi-button-negative" disabled="true"><%:Onething Demon is not running%></button>
<% end %>
</div>
</div>
<%
if container_running then
local port=util.trim(util.exec("/usr/libexec/istorec/demon.sh port"))
if port == "" then
port="18888"
end
-%>
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title">&nbsp;</label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" name="start" value="<%:Open the Onething Demon%>" onclick="window.open('http://'+location.hostname+':<%=port%>/', '_blank')">
</div>
</div>
<% end %>

View File

@@ -0,0 +1,32 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Onething Demon"
msgstr "容器魔王"
msgid "Cache path"
msgstr "缓存文件路径"
msgid "Service Status"
msgstr "服务状态"
msgid "Onething Demon status:"
msgstr "容器魔王的状态信息如下:"
msgid "Setup"
msgstr "安装配置"
msgid "The following parameters will only take effect during installation or upgrade:"
msgstr "以下参数只在安装或者升级时才会生效:"
msgid "Status"
msgstr "状态"
msgid "Onething Demon is running"
msgstr "容器魔王运行中"
msgid "Onething Demon is not running"
msgstr "容器魔王未运行"
msgid "Open the Onething Demon"
msgstr "打开容器魔王"

View File

@@ -0,0 +1,3 @@
config demon
# option 'cache_path' ''
# option 'image_name' ''

View File

@@ -0,0 +1,14 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete firewall.demon
set firewall.demon=rule
set firewall.demon.name="demon"
set firewall.demon.target="ACCEPT"
set firewall.demon.src="wan"
set firewall.demon.dest_port="1024-65535"
set firewall.demon.enabled="0"
commit firewall
EOF
exit 0

View File

@@ -0,0 +1,98 @@
#!/bin/sh
ACTION=${1}
shift 1
do_install() {
local path=`uci -q get demon.@demon[0].cache_path 2>/dev/null`
local image_name=`uci -q get demon.@demon[0].image_name 2>/dev/null`
local port=`uci -q get demon.@demon[0].port 2>/dev/null`
if [ -z "$path" ]; then
echo "path is empty!"
exit 1
fi
if [ -z "$port" ]; then
port=18888
fi
[ -z "$image_name" ] && image_name="images-cluster.xycloud.com/wxedge/amd64-wxedge:3.5.1-CTWXKS1748570956"
docker pull "$image_name"
docker rm -f onethingdemon
docker rm -f wxedge
local cmd="docker run --restart=unless-stopped -d \
--privileged \
--network=host \
--dns=127.0.0.1 \
--dns=223.5.5.5 \
--tmpfs /run \
--tmpfs /tmp \
-v \"$path:/storage\" \
-v \"$path/containerd:/var/lib/containerd\" \
-e \"LISTEN_ADDR=:${port}\" \
-e PLACE=CTKS"
local tz="`uci get system.@system[0].zonename | sed 's/ /_/g'`"
[ -z "$tz" ] || cmd="$cmd -e TZ=$tz"
cmd="$cmd --name onethingdemon \"$image_name\""
echo "$cmd"
eval "$cmd"
if [ "$?" = "0" ]; then
if [ "`uci -q get firewall.demon.enabled`" = 0 ]; then
uci -q batch <<-EOF >/dev/null
set firewall.demon.enabled="1"
commit firewall
EOF
/etc/init.d/firewall reload
fi
fi
}
usage() {
echo "usage: $0 sub-command"
echo "where sub-command is one of:"
echo " install Install the demon"
echo " upgrade Upgrade the demon"
echo " rm/start/stop/restart Remove/Start/Stop/Restart the demon"
echo " status Onething Demon status"
echo " port Onething Demon port"
}
case ${ACTION} in
"install")
do_install
;;
"upgrade")
do_install
;;
"rm")
docker rm -f onethingdemon
if [ "`uci -q get firewall.demon.enabled`" = 1 ]; then
uci -q batch <<-EOF >/dev/null
set firewall.demon.enabled="0"
commit firewall
EOF
/etc/init.d/firewall reload
fi
;;
"start" | "stop" | "restart")
docker ${ACTION} onethingdemon
;;
"status")
docker ps --all -f 'name=^/onethingdemon$' --format '{{.State}}'
;;
"port")
port=`uci -q get demon.@demon[0].port 2>/dev/null`
echo $port
;;
*)
usage
exit 1
;;
esac

View File

@@ -0,0 +1,11 @@
{
"luci-app-demon": {
"description": "Grant UCI access for luci-app-demon",
"read": {
"uci": [ "demon" ]
},
"write": {
"uci": [ "demon" ]
}
}
}

View File

@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=Task library
LUCI_DEPENDS:=+luci-lib-xterm +taskd
LUCI_EXTRA_DEPENDS:=taskd (>=1.0.3-1)
LUCI_EXTRA_DEPENDS:=taskd (>=1.0.3)
LUCI_PKGARCH:=all
PKG_VERSION:=1.0.23

View File

@@ -403,7 +403,7 @@ update_subscription() {
local subscription_file; subscription_file="$SUBSCRIPTIONS_DIR/$subscription_section.yaml"
if (curl -s -f --connect-timeout 15 --retry 3 -L -X GET -A "$subscription_user_agent" -D "$subscription_header_tmpfile" -o "$subscription_tmpfile" "$subscription_url"); then
log "Profile" "Subscription download successful."
if (yq -p yaml -o yaml "$subscription_tmpfile" > /dev/null 2>&1); then
if (yq -p yaml -o yaml -e 'has("proxies") or has("proxy-providers")' "$subscription_tmpfile" > /dev/null 2>&1 | grep -q "true"); then
log "Profile" "Subscription is valid."
success=1
else