mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
add bash.grant
This commit is contained in:
parent
1dcd51379a
commit
80eda9d0c8
@ -115,6 +115,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
MODIFY: {Name: "modify key sub type field value arg...", Help: "编辑", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
MODIFY: {Name: "modify key sub type field value arg...", Help: "编辑", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case ZONE: // modify key sub type zone id field value
|
case ZONE: // modify key sub type zone id field value
|
||||||
|
m.Debug("what %v %v", arg[3], kit.KeyHash(arg[3]))
|
||||||
_list_modify(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), kit.MDB_ID, arg[4], arg[5:]...)
|
_list_modify(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), kit.MDB_ID, arg[4], arg[5:]...)
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...)
|
_hash_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...)
|
||||||
|
@ -48,7 +48,7 @@ const (
|
|||||||
const C = "c"
|
const C = "c"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Name: C, Help: "系统", Commands: map[string]*ice.Command{
|
Index.Register(&ice.Context{Name: C, Help: "系统", Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, mdb.SEARCH} {
|
for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, mdb.SEARCH} {
|
||||||
for _, k := range []string{H, C, CC} {
|
for _, k := range []string{H, C, CC} {
|
||||||
@ -164,5 +164,5 @@ func init() {
|
|||||||
),
|
),
|
||||||
), KEYWORD, kit.Dict(),
|
), KEYWORD, kit.Dict(),
|
||||||
))},
|
))},
|
||||||
}})
|
}}, nil)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
const PYTHON = "python"
|
const PYTHON = "python"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Register(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
PYTHON: {Name: PYTHON, Help: "脚本命令", Value: kit.Data(
|
PYTHON: {Name: PYTHON, Help: "脚本命令", Value: kit.Data(
|
||||||
cli.SOURCE, "http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz",
|
cli.SOURCE, "http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz",
|
||||||
@ -40,5 +40,5 @@ func init() {
|
|||||||
m.Cmdy(INSTALL, path.Base(m.Conf(PYTHON, kit.META_SOURCE)), arg)
|
m.Cmdy(INSTALL, path.Base(m.Conf(PYTHON, kit.META_SOURCE)), arg)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
})
|
}, nil)
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ func init() {
|
|||||||
m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.ZONE, m.Option(kit.MDB_ZONE),
|
m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.ZONE, m.Option(kit.MDB_ZONE),
|
||||||
BEGIN_TIME, m.Time(), CLOSE_TIME, m.Time("30m"),
|
BEGIN_TIME, m.Time(), CLOSE_TIME, m.Time("30m"),
|
||||||
STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg)
|
STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg)
|
||||||
|
m.ProcessRefresh30ms()
|
||||||
}},
|
}},
|
||||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_task_modify(m, arg[0], arg[1])
|
_task_modify(m, arg[0], arg[1])
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,11 +98,9 @@ const FIELD = "field"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
FIELD: {Name: "field [name] cmd", Help: "插件", Action: map[string]*ice.Action{
|
FIELD: {Name: "field [name] cmd", Help: "插件", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
ice.RUN: {Name: "run", Help: "执行"},
|
||||||
m.Cmdy(arg)
|
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if arg = _name(m, arg); strings.Contains(arg[1], ice.NL) {
|
if arg = _name(m, arg); strings.Contains(arg[1], ice.NL) {
|
||||||
arg = append([]string{arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1]}, arg[2:]...)
|
arg = append([]string{arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1]}, arg[2:]...)
|
||||||
}
|
}
|
||||||
|
12
misc.go
12
misc.go
@ -226,9 +226,6 @@ func (c *Context) _cmd(m *Message, cmd *Command, key string, k string, h *Action
|
|||||||
m.Cmdy(kit.Split(h.Name), arg)
|
m.Cmdy(kit.Split(h.Name), arg)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
if k == RUN && !m.Right(arg) {
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
m.Log(LOG_CMDS, "%s.%s %s %d %v %s", c.Name, key, k, len(arg), arg, kit.FileLine(h.Hand, 3))
|
m.Log(LOG_CMDS, "%s.%s %s %d %v %s", c.Name, key, k, len(arg), arg, kit.FileLine(h.Hand, 3))
|
||||||
if len(h.List) > 0 && k != "search" {
|
if len(h.List) > 0 && k != "search" {
|
||||||
@ -326,6 +323,15 @@ func Display(file string, arg ...string) map[string]string {
|
|||||||
}
|
}
|
||||||
return map[string]string{"display": file, kit.MDB_STYLE: kit.Join(arg, " ")}
|
return map[string]string{"display": file, kit.MDB_STYLE: kit.Join(arg, " ")}
|
||||||
}
|
}
|
||||||
|
func Display0(n int, file string, arg ...string) map[string]string {
|
||||||
|
if file == "" {
|
||||||
|
file = kit.FileName(n+1) + ".js"
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(file, "/") {
|
||||||
|
file = path.Join("/require", kit.ModPath(n+1, file))
|
||||||
|
}
|
||||||
|
return map[string]string{"display": file, kit.MDB_STYLE: kit.Join(arg, SP)}
|
||||||
|
}
|
||||||
func MergeAction(list ...interface{}) map[string]*Action {
|
func MergeAction(list ...interface{}) map[string]*Action {
|
||||||
if len(list) == 0 {
|
if len(list) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
22
misc/bash/grant.go
Normal file
22
misc/bash/grant.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package bash
|
||||||
|
|
||||||
|
import (
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
const GRANT = "grant"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
|
"grant": {Name: "grant sid auto", Help: "授权", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) > 0 {
|
||||||
|
if m.Confirm("grant "+arg[0]+"?") == ice.TRUE {
|
||||||
|
m.Cmdy(SESS, mdb.MODIFY, GRANT, m.Option(ice.MSG_USERNAME), ice.Option{kit.MDB_HASH, arg[0]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Cmdy(SESS, arg)
|
||||||
|
}},
|
||||||
|
}})
|
||||||
|
}
|
74
misc/bash/run.go
Normal file
74
misc/bash/run.go
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package bash
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
const RUN = "run"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
|
"/run/": {Name: "/run/", Help: "执行", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
|
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Search(arg[0], func(_ *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||||
|
p := strings.ReplaceAll(kit.Select("/app/cat.sh", cmd.Meta["display"]), ".js", ".sh")
|
||||||
|
if strings.HasPrefix(p, ice.PS+ice.REQUIRE) {
|
||||||
|
m.Cmdy(web.SPIDE, ice.DEV, web.SPIDE_RAW, p)
|
||||||
|
} else {
|
||||||
|
m.Cmdy(nfs.CAT, path.Join(ice.USR_INTSHELL, p))
|
||||||
|
}
|
||||||
|
m.Debug(kit.Formats(cmd.Meta))
|
||||||
|
if m.Result() == "" || m.Result(1) == ice.ErrNotFound {
|
||||||
|
m.Set(ice.MSG_RESULT)
|
||||||
|
m.Echo("#/bin/bash\n")
|
||||||
|
list := []string{}
|
||||||
|
args := []string{}
|
||||||
|
kit.Fetch(cmd.Meta["_trans"], func(k string, v string) {
|
||||||
|
list = append(list, k)
|
||||||
|
args = append(args, kit.Format(` %s)`, k))
|
||||||
|
kit.Fetch(cmd.Meta[k], func(index int, value map[string]interface{}) {
|
||||||
|
args = append(args, kit.Format(` read -p "read %s: " v; url="$url/%s/$v" `, value[kit.MDB_NAME], value[kit.MDB_NAME]))
|
||||||
|
})
|
||||||
|
args = append(args, kit.Format(` ;;`))
|
||||||
|
})
|
||||||
|
list = append(list, "quit")
|
||||||
|
m.Echo(`
|
||||||
|
ish_sys_dev_run_action() {
|
||||||
|
select action in %s; do
|
||||||
|
if [ "$action" = "quit" ]; then break; fi
|
||||||
|
local url="run/action/run/%s/action/$action"
|
||||||
|
case $action in
|
||||||
|
%s
|
||||||
|
esac
|
||||||
|
ish_sys_dev_request $url
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
`, kit.Join(list, ice.SP), arg[0], kit.Join(args, ice.NL))
|
||||||
|
m.Echo("cat $1\n")
|
||||||
|
m.Debug("what %v", m.Result())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if m.Right(arg) && !m.PodCmd(arg) {
|
||||||
|
m.Cmdy(arg)
|
||||||
|
}
|
||||||
|
if m.Result() == "" {
|
||||||
|
m.Table()
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if m.Right(arg) {
|
||||||
|
m.Cmdy(arg)
|
||||||
|
}
|
||||||
|
}}},
|
||||||
|
})
|
||||||
|
}
|
@ -23,7 +23,7 @@ const SESS = "sess"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||||
SESS: {Name: SESS, Help: "会话流", Value: kit.Data(
|
SESS: {Name: SESS, Help: "会话流", Value: kit.Data(
|
||||||
kit.MDB_FIELD, "time,hash,status,username,hostname,pid,pwd",
|
kit.MDB_FIELD, "time,hash,status,username,hostname,pid,pwd,grant",
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
@ -44,9 +44,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg := m.Cmd(SESS, m.Option(SID))
|
msg := m.Cmd(SESS, m.Option(SID))
|
||||||
m.Option(aaa.USERNAME, msg.Append(aaa.USERNAME))
|
m.Option(ice.MSG_USERNAME, msg.Append(GRANT))
|
||||||
|
m.Option(ice.MSG_USERROLE, aaa.UserRole(m, msg.Append(GRANT)))
|
||||||
m.Option(tcp.HOSTNAME, msg.Append(tcp.HOSTNAME))
|
m.Option(tcp.HOSTNAME, msg.Append(tcp.HOSTNAME))
|
||||||
m.Warn(m.Option(aaa.USERNAME) == "", ice.ErrNotLogin, arg)
|
m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg)
|
||||||
}},
|
}},
|
||||||
"/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmdy(cli.QRCODE, m.Option(kit.MDB_TEXT), m.Option(cli.FG), m.Option(cli.BG))
|
m.Cmdy(cli.QRCODE, m.Option(kit.MDB_TEXT), m.Option(cli.FG), m.Option(cli.BG))
|
||||||
|
@ -114,6 +114,9 @@ func (m *Message) StatusTimeCountTotal(arg ...interface{}) {
|
|||||||
m.Status(kit.MDB_TIME, m.Time(), kit.MDB_COUNT, kit.Split(m.FormatSize())[0], kit.MDB_TOTAL, arg, kit.MDB_COST, m.FormatCost())
|
m.Status(kit.MDB_TIME, m.Time(), kit.MDB_COUNT, kit.Split(m.FormatSize())[0], kit.MDB_TOTAL, arg, kit.MDB_COST, m.FormatCost())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Message) Confirm(text string) string {
|
||||||
|
return m.Cmdx("space", m.Option(MSG_DAEMON), "confirm", text)
|
||||||
|
}
|
||||||
func (m *Message) Toast(text string, arg ...interface{}) { // [title [duration [progress]]]
|
func (m *Message) Toast(text string, arg ...interface{}) { // [title [duration [progress]]]
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
switch val := arg[1].(type) {
|
switch val := arg[1].(type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user