🐶 Sync 2025-11-02 14:26:26

This commit is contained in:
actions-user
2025-11-02 14:26:26 +08:00
parent 64bcc56c2a
commit ac011db799
1557 changed files with 746465 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
module("luci.controller.istoreenhance", package.seeall)
function index()
if not nixio.fs.access("/etc/config/istoreenhance") then
return
end
entry({"admin", "services", "istoreenhance"}, cbi("istoreenhance"), _("KSpeeder"), 20).dependent = true
entry({"admin", "services", "istoreenhance_status"}, call("istoreenhance_status"))
end
function istoreenhance_status()
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local port = tonumber(uci:get_first("istoreenhance", "istoreenhance", "adminport"))
local status = {
running = (sys.call("pidof iStoreEnhance >/dev/null") == 0),
port = (port or 5003)
}
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@@ -0,0 +1,34 @@
local m, s
local istoreenhance_model = require "luci.model.istoreenhance"
m = Map("istoreenhance", translate("KSpeeder"), translate("KSpeeder is a tool to fix network issues for iStore."))
m:section(SimpleSection).template = "istoreenhance_status"
s=m:section(TypedSection, "istoreenhance", translate("Global settings"))
s.addremove=false
s.anonymous=true
s:option(Flag, "enabled", translate("Enable")).rmempty=false
s:option(Value, "adminport", translate("Admin Port")).rmempty=false
s:option(Value, "port", translate("Port")).rmempty=false
o = s:option(Value, "cache", translate("Cache Path").."<b>*</b>")
o.rmempty = false
o.datatype = "string"
local blocks = istoreenhance_model.blocks()
local home = istoreenhance_model.home()
local paths, default_path = istoreenhance_model.find_paths(blocks, home, "Configs")
for _, val in pairs(paths) do
o:value(val, val)
end
o.default = default_path
return m

View File

@@ -0,0 +1,55 @@
local util = require "luci.util"
local jsonc = require "luci.jsonc"
local istoreenhance = {}
istoreenhance.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
istoreenhance.home = function()
local uci = require "luci.model.uci".cursor()
local home_dirs = {}
home_dirs["main_dir"] = uci:get_first("quickstart", "main", "main_dir", "/root")
home_dirs["Configs"] = uci:get_first("quickstart", "main", "conf_dir", home_dirs["main_dir"].."/Configs")
home_dirs["Public"] = uci:get_first("quickstart", "main", "pub_dir", home_dirs["main_dir"].."/Public")
home_dirs["Downloads"] = uci:get_first("quickstart", "main", "dl_dir", home_dirs["Public"].."/Downloads")
home_dirs["Caches"] = uci:get_first("quickstart", "main", "tmp_dir", home_dirs["main_dir"].."/Caches")
return home_dirs
end
istoreenhance.find_paths = function(blocks, home_dirs, path_name)
local default_path = ''
local configs = {}
default_path = home_dirs[path_name] .. "/iStoreEnhance"
if #blocks == 0 then
table.insert(configs, default_path)
else
for _, val in pairs(blocks) do
table.insert(configs, val .. "/" .. path_name .. "/iStoreEnhance")
end
local without_conf_dir = "/root/" .. path_name .. "/iStoreEnhance"
if default_path == without_conf_dir then
default_path = configs[1]
end
end
return configs, default_path
end
return istoreenhance

View File

@@ -0,0 +1,27 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/services/istoreenhance_status")%>', null,
function(x, st)
{
var tb = document.getElementById('istoreenhance_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<br/><em style=\"color:green\"><%:The KSpeeder service is running.%></em>'
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:Click to open KSpeeder%> \" onclick=\"window.open('http://" + window.location.hostname + ":" + st.port + "/')\"/>";
}
else
{
tb.innerHTML = '<br/><em style=\"color:red\"><%:The KSpeeder service is not running.%></em>';
}
}
}
);
//]]></script>
<fieldset class="cbi-section">
<legend><%:KSpeeder Status%></legend>
<p id="istoreenhance_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>