From 5227398cec14d1a44332adaa5283268025f2ebb5 Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 18 Mar 2022 10:32:28 +0800 Subject: [PATCH] opt some --- base/cli/forever.go | 5 +++++ base/web/spide.go | 3 +++ core/chat/pod.go | 39 ++++++++++++++++++--------------------- core/chat/website.go | 1 - core/code/publish.go | 10 +++++----- render.go | 5 +++++ 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/base/cli/forever.go b/base/cli/forever.go index 3f2d7452..8375ac6b 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -34,6 +34,11 @@ func init() { if p := kit.Env(CTX_LOG); p != "" { m.Optionv(CMD_ERRPUT, p) } + + if p := m.Cmdx(nfs.CAT, m.Conf("gdb.signal", kit.Keym(nfs.PATH))); p != "" { + m.Cmd(SYSTEM, "kill", "-n", 3, p) + } + m.Cmdy(FOREVER, kit.Select(os.Args[0], nfs.PWD+ice.BIN_ICE_BIN, kit.FileExists(ice.BIN_ICE_BIN)), SERVE, START, ice.DEV, "", aaa.USERNAME, aaa.ROOT, aaa.PASSWORD, aaa.ROOT, arg) }}, diff --git a/base/web/spide.go b/base/web/spide.go index 0d2a07b4..d04f861c 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -45,6 +45,9 @@ func _spide_list(m *ice.Message, arg ...string) { // 缓存方式 cache, save := "", "" switch arg[1] { + case "url": + m.Echo("%v", kit.Value(value, "client.url")) + return case SPIDE_RAW: cache, arg = arg[1], arg[1:] case SPIDE_MSG: diff --git a/core/chat/pod.go b/core/chat/pod.go index 7f095641..c0ec6c2e 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -19,31 +19,28 @@ func init() { ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { }}, }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - if kit.Select("", arg, 0) == "" { - m.RenderCmd(web.ROUTE) - return // 节点列表 + if m.IsCliUA() { + m.Option(ice.MSG_USERNAME, "root") + m.Option(ice.MSG_USERROLE, "root") + m.Option(ice.POD, kit.Select("", arg, 0)) + m.Cmdy(web.SHARE_LOCAL, "bin/ice.bin") + return // 下载文件 } - if len(arg) == 1 { - if m.IsCliUA() { - m.Option(ice.MSG_USERNAME, "root") - m.Option(ice.MSG_USERROLE, "tech") - m.Cmdy(web.SHARE_LOCAL, "bin/ice.bin") - return - } - if s := m.Cmdx(web.SPACE, arg[0], "web.chat.website", "show", "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); s != "" { - m.RenderResult(s) - } else { + + if len(arg) == 0 || kit.Select("", arg, 0) == "" { // 节点列表 + m.RenderCmd(web.ROUTE) + + } else if len(arg) == 1 { // 节点首页 + if m.RenderWebsite(arg[0], "index.iml", "Header", "", "River", "", "Action", "", "Footer", ""); m.Result() == "" { m.RenderIndex(web.SERVE, ice.VOLCANOS) } - return // 节点首页 + + } else if arg[1] == WEBSITE { // 节点网页 + m.RenderWebsite(arg[0], path.Join(arg[2:]...)) + + } else { // 节点命令 + m.Cmdy("/cmd/", path.Join(arg[2:]...)) } - if arg[1] == WEBSITE { - m.Cmdy(web.SPACE, arg[0], WEBSITE, ctx.ACTION, "show", path.Join(arg[2:]...)) - m.RenderResult() - return - } - // 节点命令 - m.Cmdy("/cmd/", path.Join(arg[2:]...)) }}, }}) } diff --git a/core/chat/website.go b/core/chat/website.go index 2e65545d..2427a4c9 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -191,7 +191,6 @@ func init() { }) }}, "show": {Hand: func(m *ice.Message, arg ...string) { - m.Debug(m.FormatStack()) if res, ok := _website_parse(m, m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])), arg[1:]...); ok { m.Echo(_website_template2, kit.Format(res)) } diff --git a/core/code/publish.go b/core/code/publish.go index 11eb80f2..87037739 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -143,14 +143,14 @@ func init() { } var _contexts = kit.Dict( - "misc", `# 完整版 + ice.MISC, `# 完整版 export ctx_dev={{.Option "httphost"}}; ctx_temp=$(mktemp); curl -fsSL $ctx_dev -o $ctx_temp; source $ctx_temp dev `, - "core", `# 标准版 + ice.CORE, `# 标准版 export ctx_dev={{.Option "httphost"}}; ctx_temp=$(mktemp); wget -O $ctx_temp $ctx_dev; source $ctx_temp app `, - "base", `# 官方版 -ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL https://shylinux.com; source $ctx_temp binary -ctx_temp=$(mktemp); wget -O $ctx_temp https://shylinux.com; source $ctx_temp binary + ice.BASE, `# 官方版 +ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL {{.Cmdx "spide" "shy" "url"}}; source $ctx_temp binary +ctx_temp=$(mktemp); wget -O $ctx_temp {{.Cmdx "spide" "shy" "url"}}; source $ctx_temp binary `, ) diff --git a/render.go b/render.go index 26f47a9b..6b67d9bd 100644 --- a/render.go +++ b/render.go @@ -75,6 +75,11 @@ func (m *Message) RenderRedirect(args ...interface{}) *Message { func (m *Message) RenderDownload(args ...interface{}) *Message { return m.Render(RENDER_DOWNLOAD, args...) } +func (m *Message) RenderWebsite(pod string, dir string, arg ...string) *Message { + m.Cmdy("space", pod, "website", "action", "show", dir, arg) + m.RenderResult() + return m +} func (m *Message) RenderIndex(serve, repos string, file ...string) *Message { return m.RenderDownload(path.Join(m.Conf(serve, kit.Keym(repos, "path")), kit.Select(m.Conf(serve, kit.Keym(repos, INDEX)), path.Join(file...)))) }