ok for systools
This commit is contained in:
parent
4f365df9c1
commit
8535e08fd8
@ -1,6 +1,6 @@
|
|||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
local http = require "luci.http"
|
local http = require "luci.http"
|
||||||
local docker = require "luci.model.docker"
|
local lng = require "luci.i18n"
|
||||||
local iform = require "luci.iform"
|
local iform = require "luci.iform"
|
||||||
|
|
||||||
module("luci.controller.systools", package.seeall)
|
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", "pages"}, call("systools_index")).leaf = true
|
||||||
entry({"admin", "services", "systools", "form"}, call("systools_form"))
|
entry({"admin", "services", "systools", "form"}, call("systools_form"))
|
||||||
entry({"admin", "services", "systools", "submit"}, call("systools_submit"))
|
entry({"admin", "services", "systools", "submit"}, call("systools_submit"))
|
||||||
entry({"admin", "services", "systools", "log"}, call("systools_log"))
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local const_log_end = "XU6J03M6"
|
|
||||||
local appname = "systools"
|
|
||||||
local page_index = {"admin", "services", "systools", "pages"}
|
local page_index = {"admin", "services", "systools", "pages"}
|
||||||
|
|
||||||
function redirect_index()
|
function redirect_index()
|
||||||
@ -52,15 +49,15 @@ function get_schema(data)
|
|||||||
actions = {
|
actions = {
|
||||||
{
|
{
|
||||||
name = "install",
|
name = "install",
|
||||||
text = "安装",
|
text = lng.translate("Execute"),
|
||||||
type = "apply",
|
type = "apply",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
local schema = {
|
local schema = {
|
||||||
actions = actions,
|
actions = actions,
|
||||||
containers = get_containers(data),
|
containers = get_containers(data),
|
||||||
description = "带 Web 远程桌面的 Docker 高性能版 SysTools。默认<用户名:kasm_user 密码:password> 访问官网 <a href=\"https://www.kasmweb.com/\" target=\"_blank\">https://www.kasmweb.com/</a>",
|
description = lng.translate("SysTools can fix some errors when your system is broken."),
|
||||||
title = "SysTools"
|
title = lng.translate("SysTools")
|
||||||
}
|
}
|
||||||
return schema
|
return schema
|
||||||
end
|
end
|
||||||
@ -74,23 +71,15 @@ function get_containers(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function status_container(data)
|
function status_container(data)
|
||||||
local status_value
|
|
||||||
status_value = "SysTools 未运行"
|
|
||||||
local status_c1 = {
|
local status_c1 = {
|
||||||
labels = {
|
labels = {
|
||||||
{
|
{
|
||||||
key = "状态:",
|
key = "访问:",
|
||||||
value = status_value
|
value = ""
|
||||||
},
|
|
||||||
{
|
|
||||||
key = "访问:",
|
|
||||||
value = ""
|
|
||||||
-- value = "'<a href=\"https://' + location.host + ':6901\" target=\"_blank\">SysTools 桌面</a>'"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
description = "访问链接是一个自签名的 https,需要浏览器同意才能访问!",
|
description = lng.translate("The running status"),
|
||||||
title = "服务状态"
|
title = lng.translate("Status")
|
||||||
}
|
}
|
||||||
return status_c1
|
return status_c1
|
||||||
end
|
end
|
||||||
@ -109,7 +98,7 @@ function main_container(data)
|
|||||||
{
|
{
|
||||||
name = "tool",
|
name = "tool",
|
||||||
required = true,
|
required = true,
|
||||||
title = "安装版本",
|
title = "可执行操作",
|
||||||
type = "string",
|
type = "string",
|
||||||
enum = {"speedtest", "reset_rom"},
|
enum = {"speedtest", "reset_rom"},
|
||||||
enumNames = {"网络测速", "恢复系统软件包"}
|
enumNames = {"网络测速", "恢复系统软件包"}
|
||||||
@ -123,8 +112,8 @@ function main_container(data)
|
|||||||
enumNames = {"ServerTest1", "ServerTest2"}
|
enumNames = {"ServerTest1", "ServerTest2"}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description = "请选择合适的版本进行安装:",
|
description = lng.translate("Select the action to run:"),
|
||||||
title = "服务操作"
|
title = lng.translate("Actions")
|
||||||
}
|
}
|
||||||
return main_c2
|
return main_c2
|
||||||
end
|
end
|
||||||
@ -147,14 +136,8 @@ function systools_submit()
|
|||||||
local json_parse = jsonc.parse
|
local json_parse = jsonc.parse
|
||||||
local content = http.content()
|
local content = http.content()
|
||||||
local req = json_parse(content)
|
local req = json_parse(content)
|
||||||
if req["$apply"] == "upgrade" then
|
if req["$apply"] == "install" then
|
||||||
result = install_upgrade_systools(req)
|
result = install_execute_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()
|
|
||||||
end
|
end
|
||||||
http.prepare_content("application/json")
|
http.prepare_content("application/json")
|
||||||
local resp = {
|
local resp = {
|
||||||
@ -166,39 +149,16 @@ function systools_submit()
|
|||||||
http.write_json(resp)
|
http.write_json(resp)
|
||||||
end
|
end
|
||||||
|
|
||||||
function systools_log()
|
function install_execute_systools(req)
|
||||||
iform.response_log("/var/log/"..appname..".log")
|
|
||||||
end
|
|
||||||
|
|
||||||
function install_upgrade_systools(req)
|
|
||||||
local password = req["tool"]
|
local password = req["tool"]
|
||||||
local port = req["server"]
|
local port = req["server"]
|
||||||
|
|
||||||
local exec_cmd = string.format("/usr/share/systools/install.sh %s", req["$apply"])
|
cmd = "/etc/init.d/tasks task_add systools " .. luci.util.shellquote(string.format("/usr/libexec/istorec/systools.sh %s", req["$apply"]))
|
||||||
iform.fork_exec(exec_cmd)
|
os.execute(cmd .. " >/dev/null 2>&1")
|
||||||
|
|
||||||
local result = {
|
local result = {
|
||||||
async = true,
|
async = true,
|
||||||
exec = exec_cmd,
|
async_state = "systools"
|
||||||
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
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<%+header%>
|
<%+header%>
|
||||||
|
|
||||||
|
<%+tasks/embed%>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function(){
|
(function(){
|
||||||
})();
|
})();
|
||||||
@ -14,18 +16,12 @@
|
|||||||
logApi:"/cgi-bin/luci/admin/services/systools/log",
|
logApi:"/cgi-bin/luci/admin/services/systools/log",
|
||||||
submitApi:"/cgi-bin/luci/admin/services/systools/submit",
|
submitApi:"/cgi-bin/luci/admin/services/systools/submit",
|
||||||
getHook:function(resp){
|
getHook:function(resp){
|
||||||
var c1 = resp.result.schema.containers[0];
|
|
||||||
if (resp.result.data.container_install) {
|
|
||||||
c1.labels[1].value = '<a href="https://'+location.host+':'+resp.result.data.port+'" target="_blank">SysTools 桌面链接</a>';
|
|
||||||
} else {
|
|
||||||
c1.labels[1].value = "安装并运行之后,才能用网页访问";
|
|
||||||
}
|
|
||||||
window.IstoreosData = resp.result.data;
|
window.IstoreosData = resp.result.data;
|
||||||
console.log("resp=", resp.result.data);
|
console.log("resp=", resp.result.data);
|
||||||
return resp;
|
return resp;
|
||||||
},
|
},
|
||||||
onFormChange: function(changedField, val) {
|
onFormChange: function(changedField, val) {
|
||||||
console.log("formChanged=", val)
|
console.log("changedField=", changedField, "formChanged=", val)
|
||||||
if (changedField === "tool" && window.IstoreosData["tool"] !== val["tool"]) {
|
if (changedField === "tool" && window.IstoreosData["tool"] !== val["tool"]) {
|
||||||
val["reload"] = true;
|
val["reload"] = true;
|
||||||
val["tool"] = 'test'
|
val["tool"] = 'test'
|
||||||
|
@ -1,62 +1,8 @@
|
|||||||
msgid "ubuntu"
|
msgid "SysTools"
|
||||||
msgstr "ubuntu"
|
msgstr "系统工具"
|
||||||
|
|
||||||
msgid "The ubuntu service is running."
|
msgid "Execute"
|
||||||
msgstr "ubuntu已启动"
|
msgstr "执行"
|
||||||
|
|
||||||
msgid "The ubuntu service is not running."
|
msgid "SysTools can fix some errors when your system is broken."
|
||||||
msgstr "ubuntu服务未启动"
|
msgstr "SysTools 可以修复一些系统问题。"
|
||||||
|
|
||||||
msgid "The ubuntu service is not installed."
|
|
||||||
msgstr "ubuntu服务未安装"
|
|
||||||
|
|
||||||
msgid "open ubuntu"
|
|
||||||
msgstr "打开ubuntu"
|
|
||||||
|
|
||||||
msgid "stop ubuntu"
|
|
||||||
msgstr "停止ubuntu"
|
|
||||||
|
|
||||||
msgid "run ubuntu"
|
|
||||||
msgstr "启动ubuntu"
|
|
||||||
|
|
||||||
msgid "uninstall ubuntu"
|
|
||||||
msgstr "删除ubuntu"
|
|
||||||
|
|
||||||
msgid "install ubuntu"
|
|
||||||
msgstr "安装ubuntu"
|
|
||||||
|
|
||||||
msgid "Collecting data..."
|
|
||||||
msgstr "收集数据..."
|
|
||||||
|
|
||||||
msgid "storage path"
|
|
||||||
msgstr "存储路径(建议插入U盘或硬盘,然后输入路径。例如:/mnt/sda1/ubuntu)"
|
|
||||||
|
|
||||||
msgid "Storage path could not be empty!"
|
|
||||||
msgstr "存储路径不能为空!"
|
|
||||||
|
|
||||||
msgid "Version"
|
|
||||||
msgstr "系统版本"
|
|
||||||
|
|
||||||
msgid "Port (optional)"
|
|
||||||
msgstr "端口"
|
|
||||||
|
|
||||||
msgid "Password (optional)"
|
|
||||||
msgstr "密码"
|
|
||||||
|
|
||||||
msgid "standard version"
|
|
||||||
msgstr "标准版本"
|
|
||||||
|
|
||||||
msgid "full version"
|
|
||||||
msgstr "全量版本"
|
|
||||||
|
|
||||||
msgid "UserName"
|
|
||||||
msgstr "用户名"
|
|
||||||
|
|
||||||
msgid "Password"
|
|
||||||
msgstr "密码"
|
|
||||||
|
|
||||||
msgid "LanAddress"
|
|
||||||
msgstr "内网地址"
|
|
||||||
|
|
||||||
msgid "WanAddress"
|
|
||||||
msgstr "外网地址"
|
|
||||||
|
46
applications/luci-app-systools/root/usr/libexec/istorec/systools.sh
Executable file
46
applications/luci-app-systools/root/usr/libexec/istorec/systools.sh
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Author Xiaobao(xiaobao@linkease.com)
|
||||||
|
|
||||||
|
ACTION=${1}
|
||||||
|
shift 1
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
echo "starting"
|
||||||
|
sleep 120
|
||||||
|
echo "started"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $0 sub-command"
|
||||||
|
echo "where sub-command is one of:"
|
||||||
|
echo " install Install the emby"
|
||||||
|
echo " upgrade Upgrade the emby"
|
||||||
|
echo " rm/start/stop/restart Remove/Start/Stop/Restart the emby"
|
||||||
|
echo " status Emby status"
|
||||||
|
echo " port Emby port"
|
||||||
|
}
|
||||||
|
|
||||||
|
case ${ACTION} in
|
||||||
|
"install")
|
||||||
|
do_install
|
||||||
|
;;
|
||||||
|
"upgrade")
|
||||||
|
do_install
|
||||||
|
;;
|
||||||
|
"rm")
|
||||||
|
docker rm -f emby
|
||||||
|
;;
|
||||||
|
"start" | "stop" | "restart")
|
||||||
|
docker ${ACTION} emby
|
||||||
|
;;
|
||||||
|
"status")
|
||||||
|
docker ps --all -f 'name=emby' --format '{{.State}}'
|
||||||
|
;;
|
||||||
|
"port")
|
||||||
|
docker ps --all -f 'name=emby' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
x
Reference in New Issue
Block a user