update 2026-10-07 18:47:42

This commit is contained in:
action committed 2026-10-07 18:47:42 +08:00
1 parent 617f7ca2a6
commit bd061545ed
4832 files changed
+1693456

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
#
# Copyright (C) 2026 KaiPlus Contributors
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=KaiPlus
PKG_VERSION:=1.0.9
PKG_RELEASE:=3
LUCI_DEPENDS:=+kaiplus +luci-compat +luci-lib-linkeaseauth +linkease-app-entry
LUCI_MINIFY_CSS:=0
LUCI_MINIFY_JS:=0
define Package/luci-app-kaiplus/conffiles
/etc/config/kaiplus
endef
define Package/luci-app-kaiplus/postrm
#!/bin/sh
rm -f /tmp/luci-indexcache
exit 0
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -0,0 +1,41 @@
module("luci.controller.kaiplus", package.seeall)
function index()
entry({"admin", "services", "kaiplus_status"}, call("kaiplus_status"))
local open = entry({"admin", "services", "kaiplus", "open"}, call("kaiplus_open"))
open.leaf = true
open.dependent = false
open.sysauth = "root"
open.sysauth_authenticator = "htmlauth"
if not nixio.fs.access("/etc/config/kaiplus") then return end
entry({"admin", "services", "kaiplus"}, cbi("kaiplus"), _("KaiPlus"), 100).dependent = true
end
local function compat()
local dispatcher = require "luci.dispatcher"
return require("luci.model.linkease.apps_compat").new({
http = require "luci.http",
resolver = require("luci.model.linkease.apps_openwrt").new(),
auth_url = dispatcher.build_url("admin", "services", "linkease_auth", "auth")
})
end
function kaiplus_status()
local sys = require "luci.sys"
local uci = require("luci.model.uci").cursor()
local external_port_enabled = uci:get_first("kaiplus", "kaiplus", "external_port_enabled") == "1"
compat():legacy_status("kaiplus", {
running = sys.call("pidof kaiplus_bin >/dev/null") == 0,
port = uci:get_first("kaiplus", "kaiplus", "port") or "8189",
base_path = uci:get_first("kaiplus", "kaiplus", "base_path") or "/apps/kaiplus/",
listen_mode = uci:get_first("kaiplus", "kaiplus", "listen_mode") or "auto",
socket_path = uci:get_first("kaiplus", "kaiplus", "socket_path") or "/var/run/kaiplus.sock",
external_port_enabled = external_port_enabled,
lan_ip = uci:get("network", "lan", "ipaddr") or ""
})
end
function kaiplus_open()
compat():open("kaiplus")
end
@@ -0,0 +1,71 @@
local m, s
local sys = require "luci.sys"
m = Map("kaiplus", translate("KaiPlus"), translate("KaiPlus is an AI workspace and session service."))
m:section(SimpleSection).template = "kaiplus/kaiplus_status"
m.on_after_commit = function(self)
sys.call("/etc/init.d/kaiplus restart >/dev/null 2>&1")
if sys.call("[ -x /etc/init.d/linkease ]") == 0 then
sys.call("/etc/init.d/linkease restart >/dev/null 2>&1 &")
end
end
s = m:section(TypedSection, "kaiplus", translate("Global settings"))
s.addremove = false
s.anonymous = true
s:option(Flag, "enabled", translate("Enable")).rmempty = false
local kaiplus_model = require "luci.model.kaiplus"
local blocks = kaiplus_model.blocks()
local home = kaiplus_model.home()
local data_dir = s:option(Value, "data_dir", translate("Data directory"))
data_dir.rmempty = false
data_dir.description = translate("Required. KaiPlus stores workspace, cache, config, and state under this directory.")
local paths, default_path = kaiplus_model.find_paths(blocks, home, "Configs")
for _, val in pairs(paths) do
data_dir:value(val, val)
end
data_dir.default = default_path
local listen_mode = s:option(ListValue, "listen_mode", translate("Listen mode"))
listen_mode:value("auto", translate("Auto"))
listen_mode:value("unix", translate("Unix socket"))
listen_mode:value("tcp", translate("TCP port"))
listen_mode.default = "auto"
listen_mode.rmempty = false
local external_port_enabled = s:option(Flag, "external_port_enabled", translate("Enable external port access"))
external_port_enabled.default = "0"
external_port_enabled.rmempty = false
local socket_path = s:option(Value, "socket_path", translate("Unix socket path"))
socket_path.default = "/var/run/kaiplus.sock"
socket_path.rmempty = false
socket_path.readonly = true
local port = s:option(Value, "port", translate("Web port"))
port.default = "8189"
port.rmempty = false
port.datatype = "port"
port.description = translate("Port for the KaiPlus web service.")
local bind_addr = s:option(Value, "bind_addr", translate("Bind address"))
bind_addr.default = "0.0.0.0"
bind_addr.rmempty = false
local base_path = s:option(Value, "base_path", translate("Base path"))
base_path.default = "/apps/kaiplus/"
base_path.rmempty = false
base_path.readonly = true
local release_channel = s:option(ListValue, "release_channel", translate("Release channel"))
release_channel:value("stable", translate("Stable"))
release_channel:value("canary", translate("Canary"))
release_channel.default = "stable"
release_channel.rmempty = false
return m
+52
View File
@@ -0,0 +1,52 @@
local jsonc = require "luci.jsonc"
local kaiplus = {}
kaiplus.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
kaiplus.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
kaiplus.find_paths = function(blocks, home_dirs, path_name)
local default_path = home_dirs[path_name] .. "/KAIPlus"
local paths = {}
if #blocks == 0 then
table.insert(paths, default_path)
else
for _, val in pairs(blocks) do
table.insert(paths, val .. "/" .. path_name .. "/KAIPlus")
end
local without_conf_dir = "/root/" .. path_name .. "/KAIPlus"
if default_path == without_conf_dir then
default_path = paths[1]
end
end
return paths, default_path
end
return kaiplus
@@ -0,0 +1,31 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/services/kaiplus_status")%>', null, function(x, st) {
var el = document.getElementById('kaiplus_status');
if (st && el) {
var status = st.running
? '<br/><em style=\"color:green\"><%:The KaiPlus service is running.%></em>'
: '<br/><em style=\"color:red\"><%:The KaiPlus service is not running.%></em>';
if (st.proxy_prefix_enabled && st.app_entry_running) {
status = status + '<br/><em><%:Access mode: LinkEase Desktop proxy.%></em>';
}
else if (st.external_port_enabled) {
status = status + '<br/><em><%:Access mode: external port.%></em>';
}
else {
status = status + '<br/><em><%:External port access is disabled.%></em>';
}
el.innerHTML = status;
if (st.running) {
el.innerHTML = el.innerHTML
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:Click to open KaiPlus%> \" onclick=\"window.open('<%=url("admin/services/kaiplus/open")%>')\"/>";
}
}
});
//]]></script>
<fieldset class="cbi-section">
<legend><%:Status%></legend>
<p id="kaiplus_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>