1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shaoying 2019-06-19 22:16:06 +08:00
parent 1ff338f367
commit 341447415f
8 changed files with 76 additions and 37 deletions

View File

@ -148,6 +148,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}, Help: "运行环境"},
"compile": &ctx.Config{Name: "compile", Value: map[string]interface{}{
"bench": "src/examples/app/bench.go",
"tmp": "var/tmp/go",
"env": []interface{}{"GOPATH", "PATH"},
}, Help: "运行环境"},
"publish": &ctx.Config{Name: "publish", Value: map[string]interface{}{
@ -574,7 +575,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
"compile": &ctx.Command{Name: "compile [OS [ARCH]]", Help: "解析脚本, script: 脚本文件, stdio: 命令终端, snippet: 代码片段", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) > 0 && arg[0] == "self" {
if m.Cmdy("cli.system", "go", "install", m.Cmdx("nfs.path", m.Conf("compile", "bench"))); m.Result(0) == "" {
m.Cmdy("cli.quit", 2)
m.Cmdy("cli.quit", 1)
}
return
}
@ -598,10 +599,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
name := strings.Join([]string{"bench", goos, arch}, "_")
wd, _ := os.Getwd()
os.MkdirAll("var/tmp", 0777)
os.MkdirAll(m.Conf("compile", "tmp"), 0777)
env := []string{"cmd_env", "GOOS", goos, "cmd_env", "GOARCH", arch, "cmd_env",
"cmd_env", "GOTMPDIR", path.Join(wd, "var/tmp"),
"cmd_env", "GOCACHE", path.Join(wd, "var/tmp"),
"cmd_env", "GOTMPDIR", path.Join(wd, m.Conf("compile", "tmp")),
"cmd_env", "GOCACHE", path.Join(wd, m.Conf("compile", "tmp")),
}
m.Confm("compile", "env", func(index int, key string) {
env = append(env, "cmd_env", key, kit.Select(os.Getenv(key), m.Option(key)))
@ -695,7 +696,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Table()
if restart {
m.Cmd("cli.quit", 2)
m.Cmd("cli.quit", 1)
}
return
}},
@ -706,8 +707,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
return
}
m.Cmdy("cli.system", "node.sh", "create", path.Join(m.Conf("missyou", "path"), m.Time("20060102-")+arg[0]),
"daemon", "cmd_daemon", "true")
p := path.Join(m.Conf("missyou", "path"), m.Time("20060102-")+arg[0])
m.Cmd("nfs.copy", path.Join(p, "etc/local.shy"), "usr/missyou/job.shy")
m.Confm("missyou", "local", func(index string, local string) {
m.Cmd("nfs.git", "clone", local, path.Join(p, "usr/local", index))
})
m.Cmdy("cli.system", "node.sh", "create", p, "daemon", "cmd_daemon", "true")
return
}},
"quit": &ctx.Command{Name: "quit code", Help: "停止服务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
@ -718,18 +724,24 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Echo("quit")
case "1":
m.Echo("term")
case "2":
if m.Option("cli.modal") != "action" {
m.Cmd("cli.source", m.Conf("system", "script.exit"))
m.Echo("restart")
}
case "2":
m.Echo("term")
}
m.Append("time", m.Time())
m.Append("code", code)
m.Echo(", wait 1s\n")
m.Table()
fmt.Printf("\n")
for _, v:=range m.Meta["result"] {
fmt.Printf("%v", v)
}
m.GoFunc(m, func(m *ctx.Message) {
defer func() {
os.Exit(kit.Int(code))

View File

@ -101,9 +101,9 @@ func (gdb *GDB) Start(m *ctx.Message, arg ...string) bool {
switch action {
case "QUIT":
m.Cmd("cli.quit", 0)
case "TERM":
m.Cmd("cli.quit", 1)
case "restart":
m.Cmd("cli.quit", 1)
case "TERM":
m.Cmd("cli.quit", 2)
case "upgrade":
m.Cmd("cli.upgrade", "bench")

View File

@ -1195,7 +1195,8 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
rg, e := regexp.Compile(m.Option("dir_reg"))
m.Confm("paths", func(index int, value string) bool {
p := path.Join(value, m.Option("dir_root"), arg[0])
// p := path.Join(value, m.Option("dir_root"), arg[0])
p := path.Join(value, arg[0])
if s, e := os.Stat(p); e == nil {
if s.IsDir() {
dir(m, p, 0, kit.Right(m.Has("dir_deep")), m.Confx("dir_type"), trip, rg,

View File

@ -149,6 +149,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "text", "name": "action"},
map[string]interface{}{"type": "button", "value": "行动"},
},
"exports": []interface{}{"you", "filename"},
},
},
"favor": []interface{}{
@ -209,19 +210,21 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "nfs", "dir"}, "inputs": []interface{}{
map[string]interface{}{"type": "button", "value": "回退", "click": "Back"},
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
map[string]interface{}{"type": "text", "name": "dir", "value": ""},
map[string]interface{}{"type": "text", "name": "dir", "value": "", "view": "long", "imports": []interface{}{"plugin_dir", "plugin_you"}},
map[string]interface{}{"type": "button", "value": "查看"},
},
"display": map[string]interface{}{"hide_result": true},
"exports": []interface{}{"dir", "filename", "dir"},
"dir_root": []interface{}{"/"},
},
map[string]interface{}{"componet_name": "status", "componet_help": "git",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "nfs", "git"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
map[string]interface{}{"type": "text", "name": "dir", "view": "long", "imports": "plugin_dir"},
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{
"branch", "status", "diff", "log", "update", "push", "init",
}},
@ -235,7 +238,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{
"commit", "add",
"commit", "add", "checkout",
}},
map[string]interface{}{"type": "text", "name": "commit"},
map[string]interface{}{"type": "button", "value": "执行"},
@ -459,12 +462,17 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}
msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m)
default:
m.Confm("componet", arg[0:], func(value map[string]interface{}) {
m.Add("append", "name", value["componet_name"])
m.Add("append", "help", value["componet_help"])
m.Add("append", "view", value["componet_view"])
m.Add("append", "init", m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_init"])), -1))
if kit.Right(value["componet_init"]) {
m.Add("append", "init", m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_init"])), -1))
} else {
m.Add("append", "init", "")
}
m.Add("append", "inputs", kit.Format(value["inputs"]))
m.Add("append", "exports", kit.Format(value["exports"]))
m.Add("append", "display", kit.Format(value["display"]))
@ -655,7 +663,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
defer func() { m.Back(m) }()
if !m.Options("remote_code") { // 本地调用
m.Cmdm(arg)
m.Cmdy(arg)
} else if arg[0] == "_check" { // 公有命令
m.Cmd(arg)
@ -1009,7 +1017,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}
// 执行命令
m.Cmdm(arg)
m.Cmdy(arg)
return
}},
},

View File

@ -95,9 +95,9 @@ func (web *WEB) Login(msg *ctx.Message, w http.ResponseWriter, r *http.Request)
// if msg.Confs("skip_login", msg.Option("path")) {
// return true
// }
defer func() {
msg.Log("info", "access: %s", msg.Option("access", msg.Cmdx("aaa.sess", "access")))
}()
// defer func() {
// msg.Log("info", "access: %s", msg.Option("access", msg.Cmdx("aaa.sess", "access")))
// }()
if msg.Confs("login", "cas") {
if !cas.IsAuthenticated(r) {
r.URL, _ = r.URL.Parse(r.Header.Get("index_url"))
@ -137,11 +137,7 @@ func (web *WEB) Login(msg *ctx.Message, w http.ResponseWriter, r *http.Request)
}
if msg.Log("info", "sessid: %s", msg.Option("sessid")); msg.Options("sessid") {
if msg.Log("info", "username: %s", msg.Option("username", msg.Cmd("aaa.sess", "user").Append("meta"))); msg.Options("username") {
if msg.Log("info", "nickname: %s", msg.Option("nickname", msg.Cmdx("aaa.auth", "username", msg.Option("username"), "data", "nickname"))); !msg.Options("nickname") {
msg.Option("nickname", msg.Option("username"))
}
}
msg.Log("info", "username: %s", msg.Option("username", msg.Cmd("aaa.sess", "user").Append("meta")))
}
if !msg.Options("username") && msg.Options("relay") {

View File

@ -167,6 +167,9 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
}
}
// if m.Log("info", "nickname: %s", m.Option("nickname", m.Cmdx("aaa.auth", "username", m.Option("username"), "data", "nickname"))); !m.Options("nickname") {
// m.Option("nickname", m.Option("username"))
// }
m.Append("remote_ip", m.Option("remote_ip"))
m.Append("nickname", m.Option("nickname"))
m.Echo(m.Option("username"))

View File

@ -395,7 +395,11 @@ function Plugin(field, tool, args, plugin) {
output.innerHTML = ""
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value) {
if (exports.length > 2) {
value = option[exports[2]].value + "/" + value
if (value.endsWith("/")) {
value = option[exports[2]].value + value
} else {
return
}
}
page.Sync("plugin_"+exports[0]).set(value)
});
@ -475,7 +479,8 @@ function Plugin(field, tool, args, plugin) {
switch (item.type) {
case "button":
item.onclick = function(event) {
plugin[item.click]? plugin[item.click](event, item, option, field): option.Runs(event)
action[item.click]? action[item.click](event, item, option, field):
plugin[item.click]? plugin[item.click](event, item, option, field): option.Runs(event)
}
break
@ -495,15 +500,29 @@ function Plugin(field, tool, args, plugin) {
}
var ui = kit.AppendChild(option, [{view: [item.view||""], list: [{type: "label", inner: item.label||""}, input]}])
var action = ui[name] || {}
page.plugin = field
page.input = ui[name]
index == 0 && ui[name] && ui[name].focus && ui[name].focus()
item.imports && page.Sync(item.imports).change(function(value, old) {
ui[name].value = value;
(index == total-1 || (index == total-2 && ui[name].parentNode.nextSibling.childNodes[1].type == "button")) && option.Runs(event)
page.input = action
index == 0 && action && action.focus && action.focus()
action.History = []
action.Goto = function(value) {
action.value = value;
(index == total-1 || (index == total-2 && action.parentNode.nextSibling.childNodes[1].type == "button")) && option.Runs(event)
action.History.push(value)
plugin.Back = function() {
action.History.pop()
action.History.length > 0 && action.Goto(action.History.pop())
}
return value
}
item.imports && typeof item.imports == "object" && item.imports.forEach(function(imports) {
page.Sync(imports).change(action.Goto)
})
return ui[name]
item.imports && typeof item.imports == "string" && page.Sync(item.imports).change(action.Goto)
return action
},
Select: function() {
page.plugin = field
@ -511,7 +530,7 @@ function Plugin(field, tool, args, plugin) {
},
}
var inputs = JSON.parse(tool.inputs)
var inputs = JSON.parse(tool.inputs || "[]")
inputs.map(function(item, index, inputs) {
plugin.Append(item)
})

View File

@ -140,7 +140,7 @@ kit = toolkit = {
for (var k in html) {
if (typeof html[k] == "object") {
for (var d in html[k]) {
node[k][d] = html[k][d]
node[k] && (node[k][d] = html[k][d])
}
continue
}