mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
5f3c3e4b36
commit
bb3b898dc7
@ -29,6 +29,9 @@ func init() {
|
||||
if m.Option(SERVICE) == "" {
|
||||
m.Options(m.Cmd("", ADMIN).AppendSimple(SERVICE, USERNAME, PASSWORD))
|
||||
}
|
||||
if m.Warn(m.Option(SERVICE) == "", ice.ErrNotValid, SERVICE) {
|
||||
return
|
||||
}
|
||||
content := []byte(kit.JoinKV(DF, NL, "From", m.Option(USERNAME), "To", m.Option(TO), "Subject", m.Option(SUBJECT), "Content-Type", "text/html; charset=UTF-8") + NL + NL + m.Option(CONTENT))
|
||||
auth := smtp.PlainAuth("", m.Option(USERNAME), m.Option(PASSWORD), kit.Split(m.Option(SERVICE), ice.DF)[0])
|
||||
m.Warn(smtp.SendMail(m.Option(SERVICE), auth, m.Option(USERNAME), kit.Split(m.Option(TO)), content))
|
||||
|
@ -16,10 +16,10 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
OFFER: {Name: "offer hash auto", Help: "邀请", Actions: ice.MergeActions(ice.Actions{
|
||||
INVITE: {Name: "invite email*='shylinux@163.com' content", Help: "邀请", Hand: func(m *ice.Message, arg ...string) {
|
||||
h := mdb.HashCreate(m, m.OptionSimple(EMAIL, "content"), "from", m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE)
|
||||
h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, "content"), "from", m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE)
|
||||
msg := m.Cmd("web.share", mdb.CREATE, mdb.TYPE, "field", mdb.NAME, m.PrefixKey(), mdb.TEXT, kit.Format(kit.List(h)),
|
||||
kit.Dict(ice.MSG_USERNAME, m.Option(EMAIL), ice.MSG_USERNICK, VOID, ice.MSG_USERROLE, VOID))
|
||||
m.Cmd(EMAIL, SEND, m.Option(EMAIL), "welcome to contents, please continue", ice.Render(m, ice.RENDER_ANCHOR, msg.Option(mdb.LINK)))
|
||||
m.Cmd(EMAIL, SEND, m.Option(EMAIL), "welcome to contents, please continue", ice.Render(m, ice.RENDER_ANCHOR, kit.MergeURL(msg.Option(mdb.LINK), "debug", "true")))
|
||||
}},
|
||||
ACCEPT: {Help: "接受", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(mdb.HASH) == "", ice.ErrNotValid, mdb.HASH) {
|
||||
|
@ -34,7 +34,7 @@ func _daemon_exec(m *ice.Message, cmd *exec.Cmd) {
|
||||
mdb.HashSelectUpdate(m, h, func(value ice.Map) { value[PID] = cmd.Process.Pid })
|
||||
m.Echo("%d", cmd.Process.Pid)
|
||||
m.Go(func() {
|
||||
if e := cmd.Wait(); !m.Warn(e, ice.ErrNotStart, cmd.Args) && cmd.ProcessState.Success() {
|
||||
if e := cmd.Wait(); !m.Warn(e, ice.ErrNotStart, cmd.Args) && cmd.ProcessState != nil && cmd.ProcessState.Success() {
|
||||
m.Cost(CODE, "0", ctx.ARGS, cmd.Args)
|
||||
mdb.HashModify(m, mdb.HASH, h, STATUS, STOP)
|
||||
} else {
|
||||
|
@ -97,9 +97,12 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) {
|
||||
}()
|
||||
}
|
||||
if e := cmd.Run(); !m.Warn(e, ice.ErrNotFound, cmd.Args) {
|
||||
m.Cost(CODE, cmd.ProcessState.Success(), ctx.ARGS, cmd.Args)
|
||||
m.Cost(CODE, _system_code(cmd), ctx.ARGS, cmd.Args)
|
||||
}
|
||||
m.Push(mdb.TIME, m.Time()).Push(CODE, kit.Select("1", "0", cmd.ProcessState.Success()))
|
||||
m.Push(mdb.TIME, m.Time()).Push(CODE, _system_code(cmd))
|
||||
}
|
||||
func _system_code(cmd *exec.Cmd) string {
|
||||
return kit.Select("1", "0", cmd.ProcessState != nil && cmd.ProcessState.Success())
|
||||
}
|
||||
func _system_find(m Message, bin string, dir ...string) string {
|
||||
if strings.Contains(bin, ice.DF) {
|
||||
|
@ -120,7 +120,7 @@ func init() {
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||
}},
|
||||
DREAM_OPEN: {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.CmdAppend(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
|
||||
m.Go(func() { m.Sleep3s(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
|
||||
@ -147,5 +147,5 @@ func init() {
|
||||
}
|
||||
|
||||
func DreamAction() ice.Actions {
|
||||
return gdb.EventsAction(DREAM_OPEN, DREAM_INPUTS, DREAM_TABLES, DREAM_ACTION)
|
||||
return gdb.EventsAction(DREAM_OPEN, DREAM_CLOSE, DREAM_INPUTS, DREAM_TABLES, DREAM_ACTION)
|
||||
}
|
||||
|
@ -159,9 +159,7 @@ func RenderIndex(m *ice.Message, repos string, file ...string) *ice.Message {
|
||||
}
|
||||
func RenderMain(m *ice.Message, pod, index string, arg ...ice.Any) *ice.Message {
|
||||
if script := m.Cmdx(Space(m, pod), nfs.CAT, kit.Select(ice.SRC_MAIN_JS, index)); script != "" {
|
||||
return m.Echo(kit.Renders(_main_template, ice.Maps{
|
||||
"version": renderVersion(m), "script": script,
|
||||
})).RenderResult()
|
||||
return m.Echo(kit.Renders(_main_template, ice.Maps{"version": renderVersion(m), "script": script})).RenderResult()
|
||||
}
|
||||
return RenderIndex(m, ice.VOLCANOS)
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
||||
}
|
||||
u := OptionUserWeb(m)
|
||||
m.Option(ice.MSG_USERHOST, u.Scheme+"//"+u.Host)
|
||||
m.Option(ice.MSG_SESSID, m.Option(CookieName(m.Option(ice.MSG_USERWEB))))
|
||||
m.Option(ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), m.Option(CookieName(m.Option(ice.MSG_USERWEB)))))
|
||||
if m.Optionv(ice.MSG_CMDS) == nil {
|
||||
if p := strings.TrimPrefix(r.URL.Path, key); p != "" {
|
||||
m.Optionv(ice.MSG_CMDS, strings.Split(p, ice.PS))
|
||||
|
@ -134,7 +134,7 @@ func init() {
|
||||
case LOGIN:
|
||||
m.RenderRedirect(ice.PS, ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME)))
|
||||
default:
|
||||
RenderIndex(m, "")
|
||||
RenderMain(m, "", "")
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,username,usernick,userrole,river,storm,type,name,text", mdb.EXPIRE, "72h"), ServeAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
|
||||
func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
||||
msg := m.Cmd(SPIDE, tcp.CLIENT, dev, PP(SPACE))
|
||||
uri := kit.ParseURL(strings.Replace(kit.MergeURL(msg.Append(DOMAIN), mdb.TYPE, ice.Info.NodeType, mdb.NAME, name, SHARE, ice.Info.CtxShare, RIVER, ice.Info.CtxRiver), ice.HTTP, "ws", 1))
|
||||
uri := kit.ParseURL(strings.Replace(kit.MergeURL(msg.Append(DOMAIN), mdb.TYPE, ice.Info.NodeType, mdb.NAME, name, SHARE, ice.Info.CtxShare, RIVER, ice.Info.CtxRiver, arg), ice.HTTP, "ws", 1))
|
||||
args := kit.SimpleKV("type,name,host,port", msg.Append(tcp.PROTOCOL), dev, msg.Append(tcp.HOST), msg.Append(tcp.PORT))
|
||||
m.Go(func() {
|
||||
redial := kit.Dict(m.Configv(REDIAL))
|
||||
@ -41,7 +41,7 @@ func _space_fork(m *ice.Message) {
|
||||
if conn, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(buffer["r"]), kit.Int(buffer["w"])); m.Assert(e) {
|
||||
text := kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.TEXT))
|
||||
name := strings.ToLower(kit.ReplaceAll(kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.NAME)), ice.PT, "_", ice.DF, "_"))
|
||||
args := kit.Simple(mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(SHARE, RIVER, ice.MSG_USERUA))
|
||||
args := kit.Simple(mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(SHARE, RIVER, ice.MSG_USERUA, cli.DAEMON))
|
||||
m.Go(func() {
|
||||
defer mdb.HashCreateDeferRemove(m, args, kit.Dict(mdb.TARGET, conn))()
|
||||
defer gdb.EventDeferEvent(m, SPACE_OPEN, args)(SPACE_CLOSE, args)
|
||||
@ -84,11 +84,10 @@ func _space_handle(m *ice.Message, safe bool, name string, conn *websocket.Conn)
|
||||
}
|
||||
}
|
||||
func _space_domain(m *ice.Message) (link string) {
|
||||
m.Options(ice.MSG_OPTION, ice.MSG_USERNAME, ice.MSG_OPTS, ice.MSG_USERNAME)
|
||||
return kit.GetValid(
|
||||
func() string { return ice.Info.Domain },
|
||||
func() string {
|
||||
return m.CmdAppend(SPACE, ice.OPS, cli.PWD, kit.Dict(ice.MSG_OPTS, ice.MSG_USERNAME), mdb.LINK)
|
||||
},
|
||||
func() string { return m.CmdAppend(SPACE, ice.OPS, cli.PWD, mdb.LINK) },
|
||||
func() string { return m.CmdAppend(SPACE, ice.DEV, cli.PWD, mdb.LINK) },
|
||||
func() string { return m.CmdAppend(SPACE, ice.SHY, cli.PWD, mdb.LINK) },
|
||||
func() string { return tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)) },
|
||||
|
@ -21,8 +21,6 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) {
|
||||
}).Length() == 0, ice.ErrNotRight, index, arg) {
|
||||
return
|
||||
}
|
||||
m.Debug("what %v", m.Option(ice.MSG_USERWEB))
|
||||
m.Debug("what %v", m.Option(ice.MSG_USERPOD))
|
||||
if !ctx.PodCmd(m, index, arg) {
|
||||
m.Cmdy(index, arg)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ func init() {
|
||||
|
||||
func GetSSO(m *ice.Message) string {
|
||||
link := m.Cmdx(web.SPACE, web.DOMAIN)
|
||||
if !strings.Contains(link, web.PP(CHAT, SSO)) {
|
||||
if !strings.Contains(link, web.PP(CHAT, POD)) {
|
||||
return ""
|
||||
}
|
||||
ls := strings.Split(kit.ParseURL(link).Path, ice.PS)
|
||||
|
@ -59,7 +59,7 @@ func init() {
|
||||
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }},
|
||||
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }},
|
||||
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INSERT: {Name: "insert zone* type=once,step,week name* text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(TASK, mdb.INSERT, arg)
|
||||
}},
|
||||
ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -67,7 +67,7 @@ func init() {
|
||||
case mdb.TYPE:
|
||||
m.Push(arg[0], ONCE, STEP, WEEK)
|
||||
default:
|
||||
mdb.HashInputs(m, arg)
|
||||
mdb.ZoneInputs(m, arg)
|
||||
}
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
type cache struct {
|
||||
ice.Hash
|
||||
short string `data:"word"`
|
||||
field string `data:"time,word,translation,definition"`
|
||||
field string `data:"time,word,phonetic,translation,definition"`
|
||||
list string `name:"list word auto create prunes" help:"缓存"`
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,7 @@ func init() {
|
||||
)},
|
||||
}, Commands: ice.Commands{
|
||||
SESSION: {Name: "session session window pane cmd auto", Help: "会话管理", Actions: ice.MergeActions(ice.Actions{
|
||||
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Cmd("", m.Option(mdb.NAME)).Length() == 0, func() { m.Cmd("", mdb.CREATE) })
|
||||
}},
|
||||
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmd("", mdb.CREATE) }},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ctx.ACTION) == SCRIPT {
|
||||
m.Cmdy(SCRIPT, mdb.INPUTS, arg)
|
||||
@ -102,9 +100,13 @@ func init() {
|
||||
m.Option(cli.CMD_DIR, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||
ls := kit.Split(m.Option(mdb.NAME), "-")
|
||||
name := kit.Select(ls[0], ls, 1)
|
||||
_tmux_cmd(m, NEW_SESSION, "-d", "-s", m.Option(mdb.NAME), "-n", name)
|
||||
if !cli.IsSuccess(_tmux_cmd(m, NEW_SESSION, "-d", "-s", m.Option(mdb.NAME), "-n", name)) {
|
||||
return
|
||||
}
|
||||
name = _tmux_key(m.Option(mdb.NAME), name)
|
||||
_tmux_cmd(m, SPLIT_WINDOW, "-t", kit.Keys(name, "1"), "-p", "40")
|
||||
if !cli.IsSuccess(_tmux_cmd(m, SPLIT_WINDOW, "-t", kit.Keys(name, "1"), "-p", "40")) {
|
||||
return
|
||||
}
|
||||
m.Go(func() {
|
||||
m.Sleep("1s")
|
||||
_tmux_cmd(m, SEND_KEYS, "-t", kit.Keys(name, "2"), "ish_miss_log", ENTER)
|
||||
|
Loading…
x
Reference in New Issue
Block a user