From 8535e08fd897346c43f44bc20353c0846b6076e1 Mon Sep 17 00:00:00 2001 From: janson Date: Sun, 13 Nov 2022 19:29:36 +0800 Subject: [PATCH] ok for systools --- .../luasrc/controller/systools.lua | 74 +++++-------------- .../luasrc/view/systools/main.htm | 10 +-- .../luci-app-systools/po/zh-cn/systools.po | 66 ++--------------- .../root/usr/libexec/istorec/systools.sh | 46 ++++++++++++ 4 files changed, 72 insertions(+), 124 deletions(-) create mode 100755 applications/luci-app-systools/root/usr/libexec/istorec/systools.sh diff --git a/applications/luci-app-systools/luasrc/controller/systools.lua b/applications/luci-app-systools/luasrc/controller/systools.lua index 98fc9dd..4901b82 100755 --- a/applications/luci-app-systools/luasrc/controller/systools.lua +++ b/applications/luci-app-systools/luasrc/controller/systools.lua @@ -1,6 +1,6 @@ local util = require "luci.util" local http = require "luci.http" -local docker = require "luci.model.docker" +local lng = require "luci.i18n" local iform = require "luci.iform" module("luci.controller.systools", package.seeall) @@ -11,12 +11,9 @@ function index() entry({"admin", "services", "systools", "pages"}, call("systools_index")).leaf = true entry({"admin", "services", "systools", "form"}, call("systools_form")) entry({"admin", "services", "systools", "submit"}, call("systools_submit")) - entry({"admin", "services", "systools", "log"}, call("systools_log")) end -local const_log_end = "XU6J03M6" -local appname = "systools" local page_index = {"admin", "services", "systools", "pages"} function redirect_index() @@ -52,15 +49,15 @@ function get_schema(data) actions = { { name = "install", - text = "安装", + text = lng.translate("Execute"), type = "apply", }, } local schema = { actions = actions, containers = get_containers(data), - description = "带 Web 远程桌面的 Docker 高性能版 SysTools。默认<用户名:kasm_user 密码:password> 访问官网 https://www.kasmweb.com/", - title = "SysTools" + description = lng.translate("SysTools can fix some errors when your system is broken."), + title = lng.translate("SysTools") } return schema end @@ -74,23 +71,15 @@ function get_containers(data) end function status_container(data) - local status_value - status_value = "SysTools 未运行" local status_c1 = { labels = { { - key = "状态:", - value = status_value - }, - { - key = "访问:", - value = "" - -- value = "'SysTools 桌面'" + key = "访问:", + value = "" } - }, - description = "访问链接是一个自签名的 https,需要浏览器同意才能访问!", - title = "服务状态" + description = lng.translate("The running status"), + title = lng.translate("Status") } return status_c1 end @@ -109,7 +98,7 @@ function main_container(data) { name = "tool", required = true, - title = "安装版本", + title = "可执行操作", type = "string", enum = {"speedtest", "reset_rom"}, enumNames = {"网络测速", "恢复系统软件包"} @@ -123,8 +112,8 @@ function main_container(data) enumNames = {"ServerTest1", "ServerTest2"} }, }, - description = "请选择合适的版本进行安装:", - title = "服务操作" + description = lng.translate("Select the action to run:"), + title = lng.translate("Actions") } return main_c2 end @@ -147,14 +136,8 @@ function systools_submit() local json_parse = jsonc.parse local content = http.content() local req = json_parse(content) - if req["$apply"] == "upgrade" then - result = install_upgrade_systools(req) - elseif req["$apply"] == "install" then - result = install_upgrade_systools(req) - elseif req["$apply"] == "restart" then - result = restart_systools(req) - else - result = delete_systools() + if req["$apply"] == "install" then + result = install_execute_systools(req) end http.prepare_content("application/json") local resp = { @@ -166,39 +149,16 @@ function systools_submit() http.write_json(resp) end -function systools_log() - iform.response_log("/var/log/"..appname..".log") -end - -function install_upgrade_systools(req) +function install_execute_systools(req) local password = req["tool"] local port = req["server"] - local exec_cmd = string.format("/usr/share/systools/install.sh %s", req["$apply"]) - iform.fork_exec(exec_cmd) + cmd = "/etc/init.d/tasks task_add systools " .. luci.util.shellquote(string.format("/usr/libexec/istorec/systools.sh %s", req["$apply"])) + os.execute(cmd .. " >/dev/null 2>&1") local result = { async = true, - exec = exec_cmd, - async_state = req["$apply"] - } - return result -end - -function delete_systools() - local log = iform.exec_to_log("docker rm -f systools") - local result = { - async = false, - log = log - } - return result -end - -function restart_systools() - local log = iform.exec_to_log("docker restart systools") - local result = { - async = false, - log = log + async_state = "systools" } return result end diff --git a/applications/luci-app-systools/luasrc/view/systools/main.htm b/applications/luci-app-systools/luasrc/view/systools/main.htm index b1bce78..e4cb7b8 100644 --- a/applications/luci-app-systools/luasrc/view/systools/main.htm +++ b/applications/luci-app-systools/luasrc/view/systools/main.htm @@ -1,5 +1,7 @@ <%+header%> +<%+tasks/embed%> +