1
0
forked from x/icebergs

add system.init

This commit is contained in:
shaoying 2019-12-30 02:53:28 +08:00
parent ef1a5f03e4
commit 2ea6bfde97
9 changed files with 152 additions and 54 deletions

View File

@ -44,6 +44,9 @@ func IsLocalIP(ip string) bool {
return ip == "::1" || ip == "127.0.0.1" return ip == "::1" || ip == "127.0.0.1"
} }
func (web *Frame) Login(msg *ice.Message, w http.ResponseWriter, r *http.Request) bool { func (web *Frame) Login(msg *ice.Message, w http.ResponseWriter, r *http.Request) bool {
if strings.HasPrefix(msg.Option(ice.MSG_USERURL), "/space/") {
return true
}
if msg.Options(ice.WEB_SESS) { if msg.Options(ice.WEB_SESS) {
// 会话认证 // 会话认证
sub := msg.Cmd(ice.AAA_SESS, "check", msg.Option(ice.WEB_SESS)) sub := msg.Cmd(ice.AAA_SESS, "check", msg.Option(ice.WEB_SESS))
@ -377,6 +380,14 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Done() m.Done()
m.Done() m.Done()
p := m.Conf(ice.WEB_CACHE, "meta.store")
m.Richs(ice.WEB_CACHE, nil, "*", func(key string, value map[string]interface{}) {
if f, _, e := kit.Create(path.Join(p, key[:2], key)); e == nil {
defer f.Close()
f.WriteString(kit.Formats(value))
}
})
m.Conf(ice.WEB_CACHE, "hash", kit.Dict())
m.Cmd(ice.CTX_CONFIG, "save", "web.json", ice.WEB_SPIDE, ice.WEB_FAVOR, ice.WEB_CACHE, ice.WEB_STORY, ice.WEB_SHARE) m.Cmd(ice.CTX_CONFIG, "save", "web.json", ice.WEB_SPIDE, ice.WEB_FAVOR, ice.WEB_CACHE, ice.WEB_STORY, ice.WEB_SHARE)
}}, }},
@ -540,8 +551,14 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
// 验证结果 // 验证结果
if m.Cost("%s %s: %s", res.Status, res.Header.Get("Content-Length"), res.Header.Get("Content-Type")); m.Warn(e != nil, "%s", e) { if m.Cost("%s %s: %s", res.Status, res.Header.Get("Content-Length"), res.Header.Get("Content-Type")); m.Warn(e != nil, "%s", e) {
if cache != "" {
m.Set("result")
}
return return
} else if m.Warn(res.StatusCode != http.StatusOK, "%s", res.Status) { } else if m.Warn(res.StatusCode != http.StatusOK, "%s", res.Status) {
if cache != "" {
m.Set("result")
}
return return
} }
@ -572,10 +589,18 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
m.Conf(ice.CLI_RUNTIME, "node.type", ice.WEB_SERVER) m.Conf(ice.CLI_RUNTIME, "node.type", ice.WEB_SERVER)
// 启动服务 // 启动服务
m.Target().Start(m, kit.Select("self", arg, 0)) switch kit.Select("self", arg, 0) {
case "dev":
m.Event(ice.SYSTEM_INIT)
fallthrough
case "self":
m.Target().Start(m, "self")
fallthrough
default:
m.Richs(ice.WEB_SPIDE, nil, "dev", func(key string, value map[string]interface{}) { m.Richs(ice.WEB_SPIDE, nil, "dev", func(key string, value map[string]interface{}) {
m.Cmd(ice.WEB_SPACE, "connect", "dev") m.Cmd(ice.WEB_SPACE, "connect", "dev")
}) })
}
}}, }},
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List( ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List(
kit.MDB_INPUT, "text", "name", "pod", kit.MDB_INPUT, "text", "name", "pod",
@ -813,22 +838,15 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
favor := "" favor := ""
if m.Richs(ice.WEB_FAVOR, nil, arg[0], func(key string, value map[string]interface{}) { if m.Richs(ice.WEB_FAVOR, nil, arg[0], func(key string, value map[string]interface{}) {
favor = key favor = key
}) == nil { }) == nil && len(arg) > 1 {
favor = m.Rich(ice.WEB_FAVOR, nil, kit.Data(kit.MDB_NAME, arg[0])) favor = m.Rich(ice.WEB_FAVOR, nil, kit.Data(kit.MDB_NAME, arg[0]))
m.Info("create favor: %s name: %s", favor, arg[0]) m.Log(ice.LOG_CREATE, "favor: %s name: %s", favor, arg[0])
} }
extras := []string{}
if len(arg) == 3 && arg[1] == "extra" {
extras, arg = strings.Split(arg[2], " "), arg[:1]
}
if len(arg) == 1 { if len(arg) == 1 {
// 收藏列表 // 收藏列表
m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), "", "", func(index int, value map[string]interface{}) { m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), "", "", func(index int, value map[string]interface{}) {
m.Push(kit.Format(index), value, []string{kit.MDB_TIME, kit.MDB_ID, kit.MDB_TYPE, kit.MDB_NAME, kit.MDB_TEXT}) m.Push(kit.Format(index), value, []string{kit.MDB_TIME, kit.MDB_ID, kit.MDB_TYPE, kit.MDB_NAME, kit.MDB_TEXT})
for _, k := range extras {
m.Push(k, kit.Select("", kit.Value(value, "extra."+k)))
}
}) })
return return
} }
@ -984,6 +1002,14 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
// head list data time text file // head list data time text file
switch arg[0] { switch arg[0] {
case "catch": case "catch":
if last := m.Richs(ice.WEB_STORY, "head", arg[2], nil); last != nil {
if t, e := time.ParseInLocation(ice.ICE_TIME, kit.Format(last["time"]), time.Local); e == nil {
if s, e := os.Stat(arg[2]); e == nil && s.ModTime().Before(t) {
m.Info("%s last: %s", arg[2], kit.Format(t))
break
}
}
}
fallthrough fallthrough
case "add", "upload": case "add", "upload":
// 保存数据 // 保存数据
@ -999,6 +1025,11 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
m.Log("info", "head: %v prev: %v count: %v", head, prev, count) m.Log("info", "head: %v prev: %v count: %v", head, prev, count)
}) })
if last := m.Richs(ice.WEB_STORY, nil, prev, nil); prev != "" && last != nil && last["data"] == arg[3] {
// 重复提交
break
}
// 添加节点 // 添加节点
list := m.Rich(ice.WEB_STORY, nil, kit.Dict( list := m.Rich(ice.WEB_STORY, nil, kit.Dict(
"count", count+1, "scene", arg[1], "story", arg[2], "data", arg[3], "prev", prev, "count", count+1, "scene", arg[1], "story", arg[2], "data", arg[3], "prev", prev,
@ -1064,12 +1095,18 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
for i := 0; i < 10 && list != ""; i++ { for i := 0; i < 10 && list != ""; i++ {
m.Confm(ice.WEB_STORY, kit.Keys("hash", list), func(value map[string]interface{}) { m.Confm(ice.WEB_STORY, kit.Keys("hash", list), func(value map[string]interface{}) {
// 直连节点 // 直连节点
m.Confm(ice.WEB_CACHE, kit.Keys("hash", value["data"]), func(val map[string]interface{}) { val := m.Confm(ice.WEB_CACHE, kit.Keys("hash", value["data"]))
if val == nil {
data := kit.Format(value["data"])
if f, e := os.Open(path.Join(m.Conf(ice.WEB_CACHE, "meta.store"), data[:2], data)); e != nil ||
json.NewDecoder(f).Decode(&val) != nil {
return
}
}
m.Push(list, value, []string{"key", "time", "count", "scene", "story"}) m.Push(list, value, []string{"key", "time", "count", "scene", "story"})
m.Push("drama", val["text"]) m.Push("drama", val["text"])
m.Push("data", value["data"]) m.Push("data", value["data"])
})
// 复合节点 // 复合节点
kit.Fetch(value["list"], func(key string, val string) { kit.Fetch(value["list"], func(key string, val string) {
@ -1102,11 +1139,16 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
} }
// 查询数据 // 查询数据
if node := m.Confm(ice.WEB_CACHE, kit.Keys("hash", arg[1])); node != nil { node := m.Confm(ice.WEB_CACHE, kit.Keys("hash", arg[1]))
if node == nil {
if f, e := os.Open(path.Join(m.Conf(ice.WEB_CACHE, "meta.store"), arg[1][:2], arg[1])); e != nil ||
json.NewDecoder(f).Decode(&node) != nil {
return
}
}
m.Push("data", arg[1]) m.Push("data", arg[1])
m.Push(arg[1], node, []string{"text", "time", "size", "type", "name", "file"}) m.Push(arg[1], node, []string{"text", "time", "size", "type", "name", "file"})
m.Echo("%s", node["text"]) m.Echo("%s", node["text"])
}
default: default:
if len(arg) == 1 { if len(arg) == 1 {
m.Cmd(ice.WEB_STORY, "history", arg).Table(func(index int, value map[string]string, head []string) { m.Cmd(ice.WEB_STORY, "history", arg).Table(func(index int, value map[string]string, head []string) {

View File

@ -47,10 +47,13 @@ prepare() {
curl \$ctx_dev/publish/\${bin} -o ice.bin && chmod u+x ice.bin curl \$ctx_dev/publish/\${bin} -o ice.bin && chmod u+x ice.bin
} }
start() { start() {
prepare && shutdown && while true; do while true; do
date && ice.bin \$@ 2>boot.log && echo -e "\n\nrestarting..." || break date && ice.bin \$@ 2>boot.log && echo -e "\n\nrestarting..." || break
done done
} }
serve() {
prepare && shutdown && start \$@
}
restart() { restart() {
[ -e \$ctx_pid ] && kill -2 \`cat \$ctx_pid\` || echo [ -e \$ctx_pid ] && kill -2 \`cat \$ctx_pid\` || echo
} }
@ -58,7 +61,7 @@ shutdown() {
[ -e \$ctx_pid ] && kill -3 \`cat \$ctx_pid\` || echo [ -e \$ctx_pid ] && kill -3 \`cat \$ctx_pid\` || echo
} }
cmd=\$1 && [ -n "\$cmd" ] && shift || cmd=start cmd=\$1 && [ -n "\$cmd" ] && shift || cmd=serve
\$cmd \$* \$cmd \$*
END END
chmod u+x ice.sh chmod u+x ice.sh
@ -66,7 +69,7 @@ END
build() { build() {
miss=./ && [ "$1" != "" ] && miss=$1 && shift && mkdir $miss miss=./ && [ "$1" != "" ] && miss=$1 && shift && mkdir $miss
cd $miss && prepare && go build -o ice.bin main.go && chmod u+x ice.bin && ./ice.sh start cd $miss && prepare && go build -o ice.bin main.go && chmod u+x ice.bin && ./ice.sh start serve dev
} }
cmd=build && [ "$1" != "" ] && cmd=$1 && shift cmd=build && [ "$1" != "" ] && cmd=$1 && shift

View File

@ -97,6 +97,8 @@ const ( // GDB
GDB_TIMER = "timer" GDB_TIMER = "timer"
GDB_EVENT = "event" GDB_EVENT = "event"
SYSTEM_INIT = "system.init"
SERVE_START = "serve.start" SERVE_START = "serve.start"
SERVE_CLOSE = "serve.close" SERVE_CLOSE = "serve.close"
SPACE_START = "space.start" SPACE_START = "space.start"

View File

@ -7,7 +7,7 @@ import (
"github.com/shylinux/toolkits" "github.com/shylinux/toolkits"
) )
var Index = &ice.Context{Name: "chat", Help: "聊天模块", var Index = &ice.Context{Name: "chat", Help: "聊天中心",
Caches: map[string]*ice.Cache{}, Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{ Configs: map[string]*ice.Config{
ice.CHAT_RIVER: {Name: "river", Help: "群组", Value: kit.Data()}, ice.CHAT_RIVER: {Name: "river", Help: "群组", Value: kit.Data()},
@ -16,10 +16,18 @@ var Index = &ice.Context{Name: "chat", Help: "聊天模块",
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "load", "chat.json") m.Cmd(ice.CTX_CONFIG, "load", "chat.json")
if m.Conf(ice.CLI_RUNTIME, "boot.count") == "1" { m.Watch(ice.SYSTEM_INIT, "web.chat.init")
m.Watch(ice.USER_CREATE, "web.chat./ocean", "spawn", "")
}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "save", "chat.json", ice.CHAT_RIVER)
}},
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(m.Confm(ice.CHAT_RIVER, "hash")) == 0 {
// 系统群组 // 系统群组
m.Option(ice.MSG_USERNAME, m.Conf(ice.CLI_RUNTIME, "boot.username"))
m.Option(ice.MSG_USERROLE, ice.ROLE_ROOT) m.Option(ice.MSG_USERROLE, ice.ROLE_ROOT)
m.Option(ice.MSG_USERNAME, m.Conf(ice.CLI_RUNTIME, "boot.username"))
river := m.Cmdx("web.chat./ocean", "spawn", "meet", m.Conf(ice.CLI_RUNTIME, "boot.username")) river := m.Cmdx("web.chat./ocean", "spawn", "meet", m.Conf(ice.CLI_RUNTIME, "boot.username"))
river = m.Cmdx("web.chat./steam", river, "spawn", "miss", river = m.Cmdx("web.chat./steam", river, "spawn", "miss",
"", "", "spide", "", "", "", "spide", "",
@ -41,13 +49,7 @@ var Index = &ice.Context{Name: "chat", Help: "聊天模块",
m.Cmd(ice.AAA_ROLE, "black", ice.ROLE_VOID, "enable", "dream.停止") m.Cmd(ice.AAA_ROLE, "black", ice.ROLE_VOID, "enable", "dream.停止")
} }
// 用户群组
m.Watch(ice.USER_CREATE, "web.chat./ocean", "spawn", "")
}}, }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "save", "chat.json", ice.CHAT_RIVER)
}},
ice.WEB_LOGIN: {Name: "login", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.WEB_LOGIN: {Name: "login", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 { if len(arg) > 0 {
switch arg[0] { switch arg[0] {

View File

@ -33,11 +33,22 @@ var Index = &ice.Context{Name: "code", Help: "编程模块",
"compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")}, "compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")},
"publish": {Name: "publish", Help: "发布", Value: kit.Data("path", "usr/publish")}, "publish": {Name: "publish", Help: "发布", Value: kit.Data("path", "usr/publish")},
"upgrade": {Name: "upgrade", Help: "升级", Value: kit.Data("path", "usr/publish")}, "upgrade": {Name: "upgrade", Help: "升级", Value: kit.Dict(
kit.MDB_HASH, kit.Dict(
"system", kit.Dict(
kit.MDB_LIST, kit.List(
kit.MDB_INPUT, "bin", "file", "ice.sh", "path", "ice.sh",
kit.MDB_INPUT, "bin", "file", "ice.bin", "path", "ice.bin",
),
),
),
)},
}, },
Commands: map[string]*ice.Command{ Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "load", "code.json") m.Cmd(ice.CTX_CONFIG, "load", "code.json")
m.Watch(ice.SYSTEM_INIT, "compile", "linux")
m.Watch(ice.SYSTEM_INIT, "publish", "ice.sh")
}}, }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "save", "code.json", "web.code.login") m.Cmd(ice.CTX_CONFIG, "save", "code.json", "web.code.login")
@ -92,12 +103,28 @@ var Index = &ice.Context{Name: "code", Help: "编程模块",
m.Log(ice.LOG_EXPORT, "%s: %s", arg[0], target) m.Log(ice.LOG_EXPORT, "%s: %s", arg[0], target)
}}, }},
"upgrade": {Name: "upgrade", Help: "升级", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "upgrade": {Name: "upgrade", Help: "升级", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
os.Rename("ice.sh", "ice.sh.bak") exit := true
os.Link(m.Cmd(ice.WEB_STORY, "index", m.Cmdx(ice.WEB_SPIDE, "dev", "cache", "/publish/ice.sh")).Append("file"), "ice.sh") m.Grows("upgrade", "hash.system", "", "", func(index int, value map[string]interface{}) {
if value["file"] == "ice.bin" {
value["file"] = kit.Keys("ice", m.Conf(ice.CLI_RUNTIME, "host.GOOS"), m.Conf(ice.CLI_RUNTIME, "host.GOARCH"))
}
os.Rename("ice.bin", "ice.bin.bak") h := m.Cmdx(ice.WEB_SPIDE, "dev", "cache", "/publish/"+kit.Format(value["file"]))
os.Link(m.Cmd(ice.WEB_STORY, "index", m.Cmdx(ice.WEB_SPIDE, "dev", "cache", kit.Keys("/publish/ice", if h == "" {
m.Conf(ice.CLI_RUNTIME, "host.GOOS"), m.Conf(ice.CLI_RUNTIME, "host.GOARCH")))).Append("file"), "ice.bin") exit = false
return
}
m.Cmd(ice.WEB_STORY, "add", "bin", value["path"], h)
os.Rename(kit.Format(value["path"]), kit.Keys(value["path"], "bak"))
os.Link(m.Cmd(ice.WEB_STORY, "index", h).Append("file"), kit.Format(value["path"]))
os.Chmod(kit.Format(value["path"]), 777)
m.Log(ice.LOG_EXPORT, "%s: %s", h, value["path"])
})
if exit {
m.Cmd("exit")
}
}}, }},
"login": {Name: "login", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "login": {Name: "login", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -21,7 +21,7 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
"name", "volcanos", "path", "usr/volcanos", "branch", "master", "name", "volcanos", "path", "usr/volcanos", "branch", "master",
"remote", "https://github.com/shylinux/volcanos", "remote", "https://github.com/shylinux/volcanos",
)) ))
m.Watch(ice.SERVE_START, "cli.git.check", "volcanos") m.Watch(ice.SYSTEM_INIT, "cli.git.check", "volcanos")
}}, }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}}, }},

View File

@ -4,6 +4,7 @@ import (
"github.com/shylinux/icebergs" "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli" "github.com/shylinux/icebergs/base/cli"
"github.com/shylinux/toolkits" "github.com/shylinux/toolkits"
"os"
"path" "path"
"strings" "strings"
"time" "time"
@ -52,21 +53,30 @@ var Index = &ice.Context{Name: "tmux", Help: "终端模块",
}, },
Commands: map[string]*ice.Command{ Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Watch(ice.SYSTEM_INIT, "cli.tmux.init")
m.Watch(ice.DREAM_START, "cli.tmux.auto") m.Watch(ice.DREAM_START, "cli.tmux.auto")
return
m.Watch(ice.SERVE_START, "cli.tmux.auto")
for _, p := range []string{"auto.sh", "auto.vim"} {
if m.Richs(ice.WEB_STORY, "head", p, nil) == nil {
m.Cmd(ice.WEB_STORY, "add", ice.TYPE_SHELL, p, m.Cmdx(ice.WEB_SPIDE, "shy", "cache", "GET", "/publish/"+p))
}
}
if m.Richs(ice.WEB_FAVOR, nil, ice.FAVOR_TMUX, nil) == nil {
m.Cmd(ice.WEB_FAVOR, ice.FAVOR_TMUX, ice.TYPE_SHELL, "下载脚本", `curl -s "$ctx_dev/code/zsh?cmd=download&arg=auto.sh" > auto.sh`)
m.Cmd(ice.WEB_FAVOR, ice.FAVOR_TMUX, ice.TYPE_SHELL, "加载脚本", `source auto.sh`)
}
}}, }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}}, }},
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
for _, v := range []string{"auto.sh", "auto.vim"} {
p := path.Join(m.Conf("web.code.publish", "meta.path"), v)
if _, e := os.Stat(p); e != nil && os.IsNotExist(e) {
if h := m.Cmdx(ice.WEB_SPIDE, "shy", "cache", "GET", "/publish/"+v); h != "" {
os.Link(m.Cmd(ice.WEB_STORY, "index", h).Append("file"), p)
m.Log(ice.LOG_EXPORT, "%s: %s", h, p)
}
}
}
if m.Richs(ice.WEB_FAVOR, nil, "tmux.auto", nil) == nil {
m.Cmd(ice.WEB_FAVOR, "tmux.auto", ice.TYPE_SHELL, "下载脚本", `curl -s "$ctx_dev/publish/auto.sh" -o auto.sh`)
m.Cmd(ice.WEB_FAVOR, "tmux.auto", ice.TYPE_SHELL, "加载脚本", `source auto.sh`)
}
if m.Richs(ice.WEB_FAVOR, nil, "tmux.init", nil) == nil {
m.Cmd(ice.WEB_FAVOR, "tmux.init", ice.TYPE_SHELL, "一键启动", `curl -s "$ctx_dev/publish/ice.sh" |sh`)
}
}},
"buffer": {Name: "buffer", Help: "终端", "buffer": {Name: "buffer", Help: "终端",
List: kit.List( List: kit.List(
@ -233,12 +243,12 @@ var Index = &ice.Context{Name: "tmux", Help: "终端模块",
m.Cmd(prefix, "new-session", "-ds", arg[0]) m.Cmd(prefix, "new-session", "-ds", arg[0])
} }
m.Cmdy(prefix, "send-keys", "-t", arg[0], "export ctx_dev=", kit.Select(m.Conf(ice.CLI_RUNTIME, "conf.ctx_dev"), m.Conf(ice.CLI_RUNTIME, "host.ctx_self")), "Enter")
m.Richs(ice.WEB_SPACE, nil, arg[0], func(key string, value map[string]interface{}) { m.Richs(ice.WEB_SPACE, nil, arg[0], func(key string, value map[string]interface{}) {
m.Cmdy(prefix, "send-keys", "-t", arg[0], "export ctx_dev=", kit.Select(m.Conf(ice.CLI_RUNTIME, "host.ctx_dev"), m.Conf(ice.CLI_RUNTIME, "host.ctx_self")), "Enter")
m.Cmdy(prefix, "send-keys", "-t", arg[0], "export ctx_share=", value["share"], "Enter") m.Cmdy(prefix, "send-keys", "-t", arg[0], "export ctx_share=", value["share"], "Enter")
}) })
m.Cmd(ice.WEB_FAVOR, kit.Select("tmux.init", arg, 1)).Table(func(index int, value map[string]string, head []string) { m.Cmd(ice.WEB_FAVOR, kit.Select("tmux.auto", arg, 1)).Table(func(index int, value map[string]string, head []string) {
switch value["type"] { switch value["type"] {
case "shell": case "shell":
m.Cmdy(prefix, "send-keys", "-t", arg[0], value["text"], "Enter") m.Cmdy(prefix, "send-keys", "-t", arg[0], value["text"], "Enter")

10
miss/go.mod Normal file
View File

@ -0,0 +1,10 @@
module miss
go 1.13
require github.com/shylinux/icebergs v0.1.0 // indirect
replace (
github.com/shylinux/icebergs => ../
github.com/shylinux/toolkits => ../../toolkits
)

View File

@ -279,6 +279,8 @@ func (m *Message) Spawn(arg ...interface{}) *Message {
source: m.target, source: m.target,
target: m.target, target: m.target,
R: m.R,
W: m.W,
} }
if len(arg) > 0 { if len(arg) > 0 {