forked from x/icebergs
add some
This commit is contained in:
parent
0338ef7b46
commit
0d0718e9e8
@ -87,6 +87,9 @@ const (
|
||||
REBOOT = "reboot"
|
||||
RESTART = "restart"
|
||||
INTERVAL = "interval"
|
||||
OPTS = "opts"
|
||||
ARGS = "args"
|
||||
LOGS = "logs"
|
||||
|
||||
BEGIN = "begin"
|
||||
END = "end"
|
||||
|
@ -17,6 +17,8 @@ const (
|
||||
ADD = "add"
|
||||
OSID = "osid"
|
||||
REPOS = "repos"
|
||||
UBUNTU = "ubuntu"
|
||||
CENTOS = "centos"
|
||||
ALPINE = "alpine"
|
||||
BUSYBOX = "busybox"
|
||||
RELEASE = "release"
|
||||
|
@ -134,7 +134,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
func PortRight(m *ice.Message, arg ...string) string {
|
||||
current, begin, end := mdb.Config(m, CURRENT), mdb.Config(m, BEGIN), mdb.Config(m, END)
|
||||
current, begin, end := kit.Select("20000", mdb.Config(m, CURRENT)), kit.Select("20000", mdb.Config(m, BEGIN)), kit.Select("30000", mdb.Config(m, END))
|
||||
return _port_right(m, kit.Int(kit.Select(kit.Select(begin, current), arg, 0)), kit.Int(kit.Select(begin, arg, 1)), kit.Int(kit.Select(end, arg, 2)))
|
||||
}
|
||||
func PortCmds(m *ice.Message, arg ...string) {
|
||||
|
@ -345,12 +345,12 @@ func init() {
|
||||
ctx.CMDS: {Name: "cmds name cmds*", Help: "命令", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, kit.Split(m.Option(ctx.CMDS))))
|
||||
}).StatusTimeCount(m.OptionSimple(ctx.CMDS))
|
||||
}).StatusTimeCount(m.OptionSimple(ctx.CMDS)).ProcessInner()
|
||||
}},
|
||||
nfs.FILE: {Name: "file name file*", Help: "文件", Icon: "bi bi-file-earmark-code", Hand: func(m *ice.Message, arg ...string) {
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, nfs.CAT, m.Option(nfs.FILE)))
|
||||
}).StatusTimeCount(m.OptionSimple(nfs.FILE))
|
||||
}).StatusTimeCount(m.OptionSimple(nfs.FILE)).ProcessInner()
|
||||
}},
|
||||
|
||||
cli.START: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -310,6 +310,7 @@ func init() {
|
||||
ice.MAIN: {Name: "main index", Help: "首页", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
mdb.Config(m, ice.MAIN, m.Option(ctx.INDEX))
|
||||
m.Cmd(SERVE, m.ActionKey(), arg)
|
||||
return
|
||||
}
|
||||
kit.If(mdb.Config(m, ice.MAIN), func(cmd string) { RenderPodCmd(m, "", cmd) }, func() { RenderMain(m) })
|
||||
|
@ -490,3 +490,14 @@ func SpideCache(m *ice.Message, link string) *ice.Message {
|
||||
}
|
||||
func SpideOrigin(m *ice.Message, name string) string { return m.Cmdv(SPIDE, name, CLIENT_ORIGIN) }
|
||||
func SpideURL(m *ice.Message, name string) string { return m.Cmdv(SPIDE, name, CLIENT_URL) }
|
||||
func SpideList(m *ice.Message) *ice.Message { return m.Copy(AdminCmd(m, SPIDE)) }
|
||||
func SpideReposList(m *ice.Message) *ice.Message {
|
||||
AdminCmd(m, SPIDE).Table(func(value ice.Maps) {
|
||||
if value[CLIENT_TYPE] == nfs.REPOS {
|
||||
m.Push(mdb.NAME, value[CLIENT_NAME])
|
||||
m.Push(mdb.ICONS, value[mdb.ICONS])
|
||||
}
|
||||
})
|
||||
ctx.DisplayInputKey(m, "style", "_nameicon")
|
||||
return m
|
||||
}
|
||||
|
@ -128,8 +128,12 @@ func Toast(m *ice.Message, text string, arg ...ice.Any) *ice.Message { // [title
|
||||
return m
|
||||
}
|
||||
func PushNoticeGrowXterm(m *ice.Message, title string, cmd ...ice.Any) {
|
||||
PushCmdStream(m, title).Cmd(cli.SYSTEM, cmd)
|
||||
}
|
||||
func PushCmdStream(m *ice.Message, title string) *ice.Message {
|
||||
m.Options(ctx.DISPLAY, html.PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
||||
PushNoticeGrow(m.Options(ice.MSG_TITLE, title, ice.MSG_COUNT, "0", ice.LOG_DEBUG, ice.FALSE, ice.LOG_DISABLE, ice.TRUE), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
||||
return len(buf), nil
|
||||
}, nil)).Cmd(cli.SYSTEM, cmd)
|
||||
}, nil))
|
||||
return m
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ func (s relay) Pushkey(m *ice.Message, arg ...string) {
|
||||
p := kit.Format("/home/%s/"+SSH_AUTHORIZED, m.Option(aaa.USERNAME))
|
||||
kit.If(m.Option(aaa.USERNAME) == aaa.ROOT, func() { p = kit.Format("/root/" + SSH_AUTHORIZED) })
|
||||
list := kit.Split(m.AdminCmdx(web.SPACE, m.Option(MACHINE), nfs.CAT, p), lex.NL, lex.NL)
|
||||
if key := ssh.PublicKey(m.Message, m.Option(web.SERVER)); !kit.IsIn(key, list...) {
|
||||
if key := m.PublicKey(m.Option(web.SERVER)); !kit.IsIn(key, list...) {
|
||||
m.AdminCmd(web.SPACE, m.Option(MACHINE), nfs.PUSH, p, key+lex.NL)
|
||||
m.Echo(m.AdminCmdx(web.SPACE, m.Option(MACHINE), nfs.CAT, p)).ProcessInner()
|
||||
} else {
|
||||
|
@ -28,6 +28,9 @@ const RSA = "rsa"
|
||||
|
||||
func init() {
|
||||
const (
|
||||
SSH_AUTH_KEYS = ".ssh/authorized_keys"
|
||||
SSH_RSA_PUB = ".ssh/id_rsa.pub"
|
||||
|
||||
TITLE = "title"
|
||||
BITS = "bits"
|
||||
KEY = "key"
|
||||
@ -35,6 +38,7 @@ func init() {
|
||||
)
|
||||
aaa.Index.MergeCommands(ice.Commands{
|
||||
RSA: {Name: "rsa hash auto", Help: "密钥", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd("", PUBLIC) }},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case TITLE:
|
||||
@ -64,7 +68,7 @@ func init() {
|
||||
))
|
||||
}},
|
||||
AUTHS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.CAT, kit.HomePath(".ssh/authorized_keys"))
|
||||
m.Cmdy(nfs.CAT, kit.HomePath(SSH_AUTH_KEYS))
|
||||
kit.For(strings.Split(strings.TrimSpace(m.Results()), lex.NL), func(text string) {
|
||||
if ls := kit.Split(text, " ", " "); len(ls) > 2 {
|
||||
m.Push(mdb.TYPE, ls[0])
|
||||
@ -74,13 +78,13 @@ func init() {
|
||||
})
|
||||
}},
|
||||
PUSHS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.PUSH, kit.HomePath(".ssh/authorized_keys"), arg[0])
|
||||
m.Cmd(nfs.PUSH, kit.HomePath(SSH_AUTH_KEYS), arg[0])
|
||||
}},
|
||||
PUBLIC: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if !nfs.Exists(m, kit.HomePath(".ssh/id_rsa.pub")) {
|
||||
if !nfs.Exists(m, kit.HomePath(SSH_RSA_PUB)) {
|
||||
m.Cmd("", mdb.CREATE).Options(m.Cmd("").AppendSimple()).Cmd("", mdb.EXPORT)
|
||||
}
|
||||
m.Cmdy(nfs.CAT, kit.HomePath(".ssh/id_rsa.pub"))
|
||||
m.Cmdy(nfs.CAT, kit.HomePath(SSH_RSA_PUB))
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, PRIVATE, mdb.FIELD, "time,hash,title,public,private")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.HashSelect(m, arg...).PushAction(mdb.EXPORT, mdb.REMOVE); len(arg) == 0 {
|
||||
@ -89,9 +93,3 @@ func init() {
|
||||
}},
|
||||
})
|
||||
}
|
||||
func PublicKey(m *ice.Message, server string) string {
|
||||
if m.IsWorker() {
|
||||
server = kit.Keys(ice.OPS, server)
|
||||
}
|
||||
return m.Cmdx("space", server, RSA, PUBLIC)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user