🤞 Sync 2025-12-11 10:03:47
This commit is contained in:
18
luci-app-istoreenhance/Makefile
Normal file
18
luci-app-istoreenhance/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for KSpeeder
|
||||
LUCI_DEPENDS:=+istoreenhance
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=0.4.1-r1
|
||||
# PKG_RELEASE MUST be empty for luci.mk
|
||||
PKG_RELEASE:=
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
26
luci-app-istoreenhance/luasrc/controller/istoreenhance.lua
Normal file
26
luci-app-istoreenhance/luasrc/controller/istoreenhance.lua
Normal 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
|
||||
|
||||
34
luci-app-istoreenhance/luasrc/model/cbi/istoreenhance.lua
Normal file
34
luci-app-istoreenhance/luasrc/model/cbi/istoreenhance.lua
Normal 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
|
||||
|
||||
|
||||
55
luci-app-istoreenhance/luasrc/model/istoreenhance.lua
Normal file
55
luci-app-istoreenhance/luasrc/model/istoreenhance.lua
Normal 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
|
||||
27
luci-app-istoreenhance/luasrc/view/istoreenhance_status.htm
Normal file
27
luci-app-istoreenhance/luasrc/view/istoreenhance_status.htm
Normal 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>
|
||||
27
luci-app-istoreenhance/po/zh-cn/istoreenhance.po
Normal file
27
luci-app-istoreenhance/po/zh-cn/istoreenhance.po
Normal file
@@ -0,0 +1,27 @@
|
||||
msgid "KSpeeder
|
||||
msgstr "KSpeeder"
|
||||
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "KSpeeder is a tool to fix network issues for iStore."
|
||||
msgstr "KSpeeder插件可以有效的解决一些网络问题,让 iStore 更好用。当然不安装也不会影响 iStore 基本功能。"
|
||||
|
||||
msgid "Port"
|
||||
msgstr "端口"
|
||||
|
||||
msgid "Admin Port"
|
||||
msgstr "管理端口"
|
||||
|
||||
msgid "The KSpeeder service is running."
|
||||
msgstr "服务已启动"
|
||||
|
||||
msgid "The KSpeeder service is not running."
|
||||
msgstr "服务未启动"
|
||||
|
||||
msgid "KSpeeder Status"
|
||||
msgstr "服务状态"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "收集数据..."
|
||||
|
||||
1
luci-app-istoreenhance/po/zh_Hans
Symbolic link
1
luci-app-istoreenhance/po/zh_Hans
Symbolic link
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
4
luci-app-istoreenhance/root/etc/uci-defaults/50_luci-istoreenhance
Executable file
4
luci-app-istoreenhance/root/etc/uci-defaults/50_luci-istoreenhance
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
Reference in New Issue
Block a user