mirror of
https://shylinux.com/x/icebergs
synced 2025-06-26 18:37:29 +08:00
opt dream
This commit is contained in:
parent
92febcf848
commit
5ecd91626a
@ -75,7 +75,7 @@ func init() {
|
|||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
||||||
host, domain := m.Cmd(tcp.HOST).Append(aaa.IP), OptionUserWeb(m).Hostname()
|
host, domain := m.Cmd(tcp.HOST).Append(aaa.IP), OptionUserWeb(m).Hostname()
|
||||||
m.Cmd("", ice.OptionFields(""), func(value ice.Maps) {
|
m.Cmds("", func(value ice.Maps) {
|
||||||
if value[tcp.HOST] == host {
|
if value[tcp.HOST] == host {
|
||||||
value[tcp.HOST] = domain
|
value[tcp.HOST] = domain
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,8 @@ func _dream_show(m *ice.Message, name string) {
|
|||||||
if m.Warn(name == "", ice.ErrNotValid, mdb.NAME) {
|
if m.Warn(name == "", ice.ErrNotValid, mdb.NAME) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !strings.Contains(name, "-") || !strings.HasPrefix(name, "20") {
|
kit.If(!strings.Contains(name, "-") || !strings.HasPrefix(name, "20"), func() { name = m.Time("20060102-") + name })
|
||||||
name = m.Time("20060102-") + name
|
defer m.ProcessOpen(MergePods(m, m.Option(mdb.NAME, name)))
|
||||||
}
|
|
||||||
defer m.ProcessOpen(MergePod(m, m.Option(mdb.NAME, name)))
|
|
||||||
p := path.Join(ice.USR_LOCAL_WORK, name)
|
p := path.Join(ice.USR_LOCAL_WORK, name)
|
||||||
if pid := m.Cmdx(nfs.CAT, path.Join(p, ice.Info.PidPath), kit.Dict(ice.MSG_USERROLE, aaa.TECH)); pid != "" && nfs.ExistsFile(m, "/proc/"+pid) {
|
if pid := m.Cmdx(nfs.CAT, path.Join(p, ice.Info.PidPath), kit.Dict(ice.MSG_USERROLE, aaa.TECH)); pid != "" && nfs.ExistsFile(m, "/proc/"+pid) {
|
||||||
m.Info("already exists %v", pid)
|
m.Info("already exists %v", pid)
|
||||||
@ -52,15 +50,15 @@ func _dream_show(m *ice.Message, name string) {
|
|||||||
}
|
}
|
||||||
_dream_template(m, p)
|
_dream_template(m, p)
|
||||||
defer ToastProcess(m)()
|
defer ToastProcess(m)()
|
||||||
defer m.Sleep3s()
|
defer m.Sleep300ms()
|
||||||
m.Options(cli.CMD_DIR, kit.Path(p), cli.CMD_ENV, kit.Simple(
|
m.Options(cli.CMD_DIR, kit.Path(p), cli.CMD_ENV, kit.Simple(
|
||||||
cli.CTX_OPS, "http://localhost:"+m.CmdAppend(SERVE, tcp.PORT), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_PID, ice.VAR_LOG_ICE_PID,
|
cli.CTX_OPS, "http://localhost:"+m.Cmdv(SERVE, tcp.PORT), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_PID, ice.VAR_LOG_ICE_PID,
|
||||||
cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username, kit.EnvSimple(cli.HOME, cli.TERM, cli.SHELL), mdb.Configv(m, cli.ENV),
|
cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username, kit.EnvSimple(cli.HOME, cli.TERM, cli.SHELL), mdb.Configv(m, cli.ENV),
|
||||||
), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG))
|
), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG))
|
||||||
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
||||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
||||||
m.Cmd(cli.DAEMON, kit.Select(kit.Path(os.Args[0]), cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN)),
|
m.Cmd(cli.DAEMON, kit.Select(kit.Path(os.Args[0]), cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN)),
|
||||||
SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.TYPE, WORKER, m.OptionSimple(mdb.NAME, RIVER), cli.DAEMON, ice.OPS)
|
SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.TYPE, WORKER, m.OptionSimple(mdb.NAME), cli.DAEMON, ice.OPS)
|
||||||
}
|
}
|
||||||
func _dream_template(m *ice.Message, p string) {
|
func _dream_template(m *ice.Message, p string) {
|
||||||
if m.Option(nfs.REPOS) != "" {
|
if m.Option(nfs.REPOS) != "" {
|
||||||
@ -71,21 +69,20 @@ func _dream_template(m *ice.Message, p string) {
|
|||||||
if m.Option(nfs.TEMPLATE) == "" {
|
if m.Option(nfs.TEMPLATE) == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, file := range []string{
|
kit.For([]string{ice.ETC_MISS_SH,
|
||||||
ice.ETC_MISS_SH, ice.MAKEFILE, ice.GO_MOD, ice.GO_SUM,
|
ice.LICENSE, ice.MAKEFILE, ice.README_MD, ice.GO_MOD, ice.GO_SUM,
|
||||||
ice.SRC_MAIN_GO, ice.SRC_MAIN_SHY, ice.SRC_MAIN_JS,
|
ice.SRC_MAIN_GO, ice.SRC_MAIN_SH, ice.SRC_MAIN_SHY, ice.SRC_MAIN_JS,
|
||||||
ice.README_MD,
|
}, func(file string) {
|
||||||
} {
|
|
||||||
if nfs.ExistsFile(m, path.Join(p, file)) {
|
if nfs.ExistsFile(m, path.Join(p, file)) {
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
switch m.Cmdy(nfs.COPY, path.Join(p, file), path.Join(ice.USR_LOCAL_WORK, m.Option(nfs.TEMPLATE), file)); file {
|
switch m.Cmdy(nfs.COPY, path.Join(p, file), path.Join(ice.USR_LOCAL_WORK, m.Option(nfs.TEMPLATE), file)); file {
|
||||||
case ice.GO_MOD:
|
case ice.GO_MOD:
|
||||||
kit.Rewrite(path.Join(p, file), func(line string) string {
|
kit.Rewrite(path.Join(p, file), func(line string) string {
|
||||||
return kit.Select(line, "module "+m.Option(mdb.NAME), strings.HasPrefix(line, "module"))
|
return kit.Select(line, nfs.MODULE+ice.SP+m.Option(mdb.NAME), strings.HasPrefix(line, nfs.MODULE))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -104,9 +101,7 @@ func init() {
|
|||||||
DREAM: {Name: "dream name path auto create", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
DREAM: {Name: "dream name path auto create", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
||||||
m.Cmd("", ice.OptionFields(), func(value ice.Maps) {
|
m.Cmds("", func(value ice.Maps) { m.PushSearch(mdb.TEXT, MergePods(m, value[mdb.NAME]), value) })
|
||||||
m.PushSearch(mdb.TEXT, MergePods(m, value[mdb.NAME]), value)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -117,8 +112,7 @@ func init() {
|
|||||||
if msg := m.Cmd(SPIDE, ice.OPS, SPIDE_MSG, UserHost(m)+"/x/list"); !msg.IsErr() {
|
if msg := m.Cmd(SPIDE, ice.OPS, SPIDE_MSG, UserHost(m)+"/x/list"); !msg.IsErr() {
|
||||||
m.Copy(msg)
|
m.Copy(msg)
|
||||||
}
|
}
|
||||||
for _, dev := range []string{ice.OPS, ice.DEV} {
|
for _, dev := range []string{ice.OPS, ice.DEV, ice.SHY} {
|
||||||
// for _, dev := range []string{ice.OPS, ice.DEV, ice.SHY} {
|
|
||||||
if msg := m.Cmd(SPIDE, dev, SPIDE_MSG, "/x/list"); !msg.IsErr() {
|
if msg := m.Cmd(SPIDE, dev, SPIDE_MSG, "/x/list"); !msg.IsErr() {
|
||||||
m.Copy(msg)
|
m.Copy(msg)
|
||||||
}
|
}
|
||||||
@ -137,16 +131,14 @@ func init() {
|
|||||||
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||||
m.Go(func() { m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT) })
|
m.Go(func() { m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT) })
|
||||||
m.Sleep300ms()
|
m.Sleep30ms()
|
||||||
}},
|
}},
|
||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||||
}},
|
}},
|
||||||
DREAM_CLOSE: {Hand: func(m *ice.Message, arg ...string) {
|
DREAM_CLOSE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(cli.DAEMON) == ice.OPS {
|
if m.Option(cli.DAEMON) == ice.OPS && m.Cmdv(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
|
||||||
if m.CmdAppend(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
|
m.Go(func() { m.Sleep30ms(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
|
||||||
m.Go(func() { m.Sleep3s(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -155,7 +147,7 @@ func init() {
|
|||||||
m.PushButton(OPEN)
|
m.PushButton(OPEN)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
OPEN: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessOpen(m, MergePod(m, m.Option(mdb.NAME), arg)) }},
|
OPEN: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessOpen(m, MergePods(m, m.Option(mdb.NAME), arg)) }},
|
||||||
}, ctx.CmdAction(), DreamAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, ctx.CmdAction(), DreamAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
_dream_list(m)
|
_dream_list(m)
|
||||||
|
@ -107,10 +107,10 @@ func init() {
|
|||||||
SHARE_CACHE: {Hand: func(m *ice.Message, arg ...string) { _share_cache(m, arg...) }},
|
SHARE_CACHE: {Hand: func(m *ice.Message, arg ...string) { _share_cache(m, arg...) }},
|
||||||
SHARE_LOCAL: {Hand: func(m *ice.Message, arg ...string) { ShareLocalFile(m, arg...) }},
|
SHARE_LOCAL: {Hand: func(m *ice.Message, arg ...string) { ShareLocalFile(m, arg...) }},
|
||||||
SHARE_LOCAL_AVATAR: {Hand: func(m *ice.Message, arg ...string) {
|
SHARE_LOCAL_AVATAR: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.RenderDownload(strings.TrimPrefix(m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.AVATAR), SHARE_LOCAL))
|
m.RenderDownload(strings.TrimPrefix(m.Cmdv(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.AVATAR), SHARE_LOCAL))
|
||||||
}},
|
}},
|
||||||
SHARE_LOCAL_BACKGROUND: {Hand: func(m *ice.Message, arg ...string) {
|
SHARE_LOCAL_BACKGROUND: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.RenderDownload(strings.TrimPrefix(m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.BACKGROUND), SHARE_LOCAL))
|
m.RenderDownload(strings.TrimPrefix(m.Cmdv(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.BACKGROUND), SHARE_LOCAL))
|
||||||
}},
|
}},
|
||||||
SHARE_PROXY: {Hand: func(m *ice.Message, arg ...string) { _share_proxy(m) }},
|
SHARE_PROXY: {Hand: func(m *ice.Message, arg ...string) { _share_proxy(m) }},
|
||||||
SHARE_TOAST: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, arg[0], kit.UnMarshal(m.Option("arg"))) }},
|
SHARE_TOAST: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, arg[0], kit.UnMarshal(m.Option("arg"))) }},
|
||||||
|
@ -125,7 +125,7 @@ func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
|||||||
}
|
}
|
||||||
func _space_send(m *ice.Message, name string, arg ...string) {
|
func _space_send(m *ice.Message, name string, arg ...string) {
|
||||||
wait, done := m.Wait(func(msg *ice.Message, arg ...string) {
|
wait, done := m.Wait(func(msg *ice.Message, arg ...string) {
|
||||||
m.Copy(msg).Cost(kit.Format("%v->%v %v %v", m.Optionv(ice.MSG_SOURCE), m.Optionv(ice.MSG_TARGET), m.Detailv(), m.FormatSize()))
|
m.Cost(kit.Format("%v->[%v] %v %v", m.Optionv(ice.MSG_SOURCE), name, m.Detailv(), msg.FormatSize())).Copy(msg)
|
||||||
})
|
})
|
||||||
h := mdb.HashCreate(m.Spawn(), mdb.TYPE, "send", mdb.NAME, kit.Keys(name, m.Target().ID()), mdb.TEXT, kit.Join(arg, ice.SP), kit.Dict(mdb.TARGET, done))
|
h := mdb.HashCreate(m.Spawn(), mdb.TYPE, "send", mdb.NAME, kit.Keys(name, m.Target().ID()), mdb.TEXT, kit.Join(arg, ice.SP), kit.Dict(mdb.TARGET, done))
|
||||||
defer mdb.HashRemove(m, mdb.HASH, h)
|
defer mdb.HashRemove(m, mdb.HASH, h)
|
||||||
@ -174,7 +174,7 @@ func init() {
|
|||||||
case MASTER:
|
case MASTER:
|
||||||
m.PushSearch(mdb.TEXT, m.Cmdv(SPIDE, value[mdb.NAME], CLIENT_ORIGIN), value)
|
m.PushSearch(mdb.TEXT, m.Cmdv(SPIDE, value[mdb.NAME], CLIENT_ORIGIN), value)
|
||||||
case SERVER:
|
case SERVER:
|
||||||
m.PushSearch(mdb.TEXT, tcp.PublishLocalhost(m, strings.Split(MergePod(m, value[mdb.NAME]), ice.QS)[0]), value)
|
m.PushSearch(mdb.TEXT, MergePods(m, value[mdb.NAME]), value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if arg[0] == mdb.FOREACH && arg[1] == ssh.SHELL {
|
} else if arg[0] == mdb.FOREACH && arg[1] == ssh.SHELL {
|
||||||
|
@ -292,7 +292,7 @@ func init() {
|
|||||||
m.Push(tcp.PROTOCOL, msg.Append(CLIENT_PROTOCOL)).Push(tcp.HOSTNAME, msg.Append(CLIENT_HOSTNAME))
|
m.Push(tcp.PROTOCOL, msg.Append(CLIENT_PROTOCOL)).Push(tcp.HOSTNAME, msg.Append(CLIENT_HOSTNAME))
|
||||||
}},
|
}},
|
||||||
MERGE: {Hand: func(m *ice.Message, arg ...string) {
|
MERGE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(kit.MergeURL2(m.CmdAppend("", arg[0], CLIENT_URL), arg[1], arg[2:]))
|
m.Echo(kit.MergeURL2(m.Cmdv("", arg[0], CLIENT_URL), arg[1], arg[2:]))
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url", LOGHEADERS, ice.FALSE), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url", LOGHEADERS, ice.FALSE), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user