💐 Sync 2026-03-10 20:23:29

This commit is contained in:
github-actions[bot] committed 2026-03-10 20:23:29 +08:00
1 parent 62c1cd7501
commit 52bf5fc663
26 files changed
+3712 -3272

No files matched your search

+2 -2
View File
@@ -7,8 +7,8 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=kai
PKG_VERSION:=1.0.0
PKG_RELEASE:=2
PKG_VERSION:=1.0.1
PKG_RELEASE:=3
LUCI_DEPENDS:=+kai +kai_session +luci-compat
LUCI_MINIFY_CSS:=0
LUCI_MINIFY_JS:=0
+10 -1
View File
@@ -9,11 +9,20 @@ s.anonymous=true
s:option(Flag, "enabled", translate("Enable")).rmempty=false
local kai_model = require "luci.model.kai"
local blocks = kai_model.blocks()
local home = kai_model.home()
local data_dir = s:option(Value, "data_dir", translate("Data directory"))
data_dir.placeholder = ""
data_dir.rmempty = false
data_dir.description = translate("Required. KAI session will store cwd/cache/data/config/state under this directory (subfolders: cwd, cache, data, config, state).")
local paths, default_path = kai_model.find_paths(blocks, home, "Configs")
for _, val in pairs(paths) do
data_dir:value(val, val)
end
data_dir.default = default_path
local port = s:option(Value, "port", translate("API port"))
port.default = "8197"
port.rmempty = false
+54
View File
@@ -0,0 +1,54 @@
local jsonc = require "luci.jsonc"
local kai = {}
kai.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 and obj["blockdevices"] or {}) do
local fsize = val["fssize"]
if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then
vals[#vals + 1] = val["mountpoint"]
end
end
end
return vals
end
kai.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
kai.find_paths = function(blocks, home_dirs, path_name)
local default_path = ""
local paths = {}
default_path = home_dirs[path_name] .. "/KAI"
if #blocks == 0 then
table.insert(paths, default_path)
else
for _, val in pairs(blocks) do
table.insert(paths, val .. "/" .. path_name .. "/KAI")
end
local without_conf_dir = "/root/" .. path_name .. "/KAI"
if default_path == without_conf_dir then
default_path = paths[1]
end
end
return paths, default_path
end
return kai