update 2024-07-02 20:32:00

This commit is contained in:
kenzok8 2024-07-02 20:32:00 +08:00
parent dbd8a2631d
commit 8873391316
4 changed files with 122 additions and 5 deletions

View File

@ -11,7 +11,7 @@ LUCI_DEPENDS:=+curl +opkg +luci-base +tar +coreutils +coreutils-stat +libuci-lua
LUCI_EXTRA_DEPENDS:=luci-lib-taskd (>=1.0.19)
LUCI_PKGARCH:=all
PKG_VERSION:=0.1.22-0
PKG_VERSION:=0.1.23-0
# PKG_RELEASE MUST be empty for luci.mk
PKG_RELEASE:=

View File

@ -29,6 +29,7 @@ function index()
entry({"admin", "store", "get_block_devices"}, call("get_block_devices"))
entry({"admin", "store", "configured"}, call("configured"))
entry({"admin", "store", "entrysh"}, post("entrysh"))
-- docker
entry({"admin", "store", "docker_check_dir"}, call("docker_check_dir"))
@ -36,7 +37,7 @@ function index()
entry({"admin", "store", "docker_migrate"}, post("docker_migrate"))
-- package
for _, action in ipairs({"update", "install", "upgrade", "remove"}) do
for _, action in ipairs({"update", "install", "upgrade", "remove", "autoconf"}) do
store_api(action, true)
end
for _, action in ipairs({"status", "installed"}) do
@ -302,8 +303,8 @@ function store_action(param)
end
local metapkg = pkg and (metapkgpre .. pkg) or ""
if action == "update" or pkg then
if action == "update" or action == "install" then
if action == "install" and "1" == luci.http.formvalue("autoconf") then
if action == "update" or action == "install" or action == "autoconf" then
if (action == "install" and "1" == luci.http.formvalue("autoconf")) or action == "autoconf" then
local autoenv = "AUTOCONF=" .. pkg
local autopath = luci.http.formvalue("path")
local autoenable = luci.http.formvalue("enable")
@ -416,6 +417,37 @@ function configured()
luci.http.write_json({code=200, configured=configured})
end
function entrysh()
local package = luci.http.formvalue("package")
local hostname = luci.http.formvalue("hostname")
if hostname == nil or hostname == "" or not validate_pkgname(package) then
luci.http.status(400, "Bad Request")
return
end
local result
local entryfile = "/usr/libexec/istoree/" .. package .. ".sh"
if nixio.fs.access(entryfile) then
local o = luci.util.exec(entryfile .. " status " .. luci.util.shellquote(hostname))
if o == nil or o == "" then
result = {code=500, msg="entrysh execute failed"}
else
local jsonc = require "luci.jsonc"
local json_parse = jsonc.parse
local status = json_parse(o)
if status == nil then
result = {code=500, msg="json parse failed: " .. o}
else
result = {code=200, status=status}
end
end
else
result = {code=404, msg="entrysh of this package not found"}
end
luci.http.prepare_content("application/json")
luci.http.write_json(result)
end
function docker_check_dir()
local docker_on_system = luci.sys.call("/usr/libexec/istore/docker check_dir >/dev/null 2>&1") ~= 0
luci.http.prepare_content("application/json")

View File

@ -247,6 +247,9 @@ case $action in
check_space
wrapped_in_update opkg_wrap_mirrors install "$@" && try_autoconf
;;
"autoconf")
try_autoconf
;;
"upgrade")
new_upgrade "$@"
;;

View File

@ -55,6 +55,33 @@ paths:
description: OK
schema:
$ref: "#/definitions/ResponseStore"
/cgi-bin/luci/admin/store/autoconf:
post:
tags:
- install
summary: 自动配置插件
parameters:
- in: "query"
name: "token"
type: string
required: true
- in: "query"
name: "package"
type: string
required: true
- in: "query"
name: "path"
type: string
description: "可选参数"
- in: "query"
name: "enable"
type: string
description: "可选参数"
responses:
"200":
description: OK
schema:
$ref: "#/definitions/ResponseStore"
/cgi-bin/luci/admin/store/remove:
post:
tags:
@ -205,6 +232,32 @@ paths:
description: OK
schema:
$ref: "#/definitions/ResponseStoreConfigured"
/cgi-bin/luci/admin/store/entrysh:
post:
tags:
- entrysh
summary: 查询插件运行状态,主要为了获取入口信息。
description: 调用前应该检查meta数据中autoconf数组包含entrysh注意如果是安装插件则检查服务器端的autoconf如果是调用已安装插件则检查路由器端的autoconf。
parameters:
- in: "query"
name: "token"
type: string
required: true
- in: "query"
name: "package"
type: string
required: true
description: "包名例如aria2"
- in: "query"
name: "hostname"
type: string
required: true
description: "主机名不包含端口。前端应该使用location.hostname获取"
responses:
"200":
description: OK
schema:
$ref: "#/definitions/ResponseStoreEntrysh"
/cgi-bin/luci/admin/store/docker_check_dir:
get:
tags:
@ -235,7 +288,8 @@ paths:
post:
tags:
- docker_migrate
summary: docker迁移到目标目录异步当返回code为0的时候可以使用taskd接口展示日志跟安装插件时一样
summary: docker迁移到目标目录异步
description: 当返回code为0的时候可以使用taskd接口展示日志跟安装插件时一样
parameters:
- in: "query"
name: "token"
@ -401,5 +455,33 @@ definitions:
error:
type: string
description: "当result为bad时此处返回错误日志"
ResponseStoreEntrysh:
type: object
properties:
code:
type: integer
description: "为200时"
msg:
type: string
description: "code不为200时显示错误信息"
status:
type: object
description: "状态和入口信息,不同插件可能有些不一样,仅列出常用公共参数"
properties:
app:
type: string
description: "插件名称,跟请求的包名一致"
docker:
type: boolean
description: "如果是docker插件"
running:
type: boolean
description: "是否运行中"
deployed:
type: boolean
description: "如果是docker插件且未运行则是否已经部署"
web:
type: string
description: "web端跳转url"