mirror of
https://shylinux.com/x/icebergs
synced 2025-06-26 18:37:29 +08:00
opt some
This commit is contained in:
parent
9919e3bcdf
commit
9ebe7add4a
@ -43,12 +43,14 @@ func _user_search(m *ice.Message, name, text string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserRoot(m *ice.Message) {
|
func UserRoot(m *ice.Message, arg ...string) { // password username userrole
|
||||||
m.Option(ice.MSG_USERROLE, ROOT)
|
userrole := kit.Select(ice.Info.UserName, arg, 2)
|
||||||
m.Option(ice.MSG_USERNAME, ice.Info.UserName)
|
username := kit.Select(ice.Info.UserName, arg, 1)
|
||||||
|
m.Option(ice.MSG_USERROLE, userrole)
|
||||||
|
m.Option(ice.MSG_USERNAME, username)
|
||||||
|
|
||||||
if !_user_exists(m, ice.Info.UserName) {
|
if !_user_exists(m, username) {
|
||||||
_user_create(m, ROOT, ice.Info.UserName, "")
|
_user_create(m, userrole, username, kit.Select("", arg, 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func UserRole(m *ice.Message, username interface{}) (role string) {
|
func UserRole(m *ice.Message, username interface{}) (role string) {
|
||||||
|
@ -55,6 +55,7 @@ func _runtime_init(m *ice.Message) {
|
|||||||
// 启动次数
|
// 启动次数
|
||||||
count := kit.Int(m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT))) + 1
|
count := kit.Int(m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT))) + 1
|
||||||
m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT), count)
|
m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT), count)
|
||||||
|
m.Conf(RUNTIME, kit.Keys(BOOT, ice.BIN), m.Cmdx(SYSTEM, "which", os.Args[0]))
|
||||||
|
|
||||||
// 节点信息
|
// 节点信息
|
||||||
m.Conf(RUNTIME, kit.Keys(NODE, mdb.TIME), m.Time())
|
m.Conf(RUNTIME, kit.Keys(NODE, mdb.TIME), m.Time())
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
@ -63,7 +64,7 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
m.Push(CMD_OUT, out.String())
|
m.Push(CMD_OUT, out.String())
|
||||||
m.Push(CMD_ERR, err.String())
|
m.Push(CMD_ERR, err.String())
|
||||||
m.Echo(kit.Select(out.String(), err.String()))
|
m.Echo(strings.TrimSpace(kit.Select(out.String(), err.String())))
|
||||||
}()
|
}()
|
||||||
cmd.Stdout, cmd.Stderr = out, err
|
cmd.Stdout, cmd.Stderr = out, err
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func CookieName(url string) string {
|
|||||||
func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path expire
|
func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path expire
|
||||||
expire := time.Now().Add(kit.Duration(kit.Select(msg.Conf(aaa.SESS, "meta.expire"), arg, 2)))
|
expire := time.Now().Add(kit.Duration(kit.Select(msg.Conf(aaa.SESS, "meta.expire"), arg, 2)))
|
||||||
http.SetCookie(msg.W, &http.Cookie{Value: value,
|
http.SetCookie(msg.W, &http.Cookie{Value: value,
|
||||||
Name: kit.Select(ice.MSG_SESSID, arg, 0), Path: kit.Select("/", arg, 1), Expires: expire})
|
Name: kit.Select(CookieName(msg.Option(ice.MSG_USERWEB)), arg, 0), Path: kit.Select(ice.PS, arg, 1), Expires: expire})
|
||||||
}
|
}
|
||||||
func RenderType(w http.ResponseWriter, name, mime string) {
|
func RenderType(w http.ResponseWriter, name, mime string) {
|
||||||
if mime != "" {
|
if mime != "" {
|
||||||
|
@ -284,10 +284,11 @@ func init() {
|
|||||||
m.Config(kit.Keys(aaa.WHITE, k), ice.TRUE)
|
m.Config(kit.Keys(aaa.WHITE, k), ice.TRUE)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
cli.START: {Name: "start dev name=ops proto=http host port=9020 nodename", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
cli.START: {Name: "start dev name=ops proto=http host port=9020 nodename password username userrole", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if cli.NodeInfo(m, SERVER, kit.Select(ice.Info.HostName, m.Option("nodename"))); m.Option(tcp.PORT) == tcp.RANDOM {
|
if cli.NodeInfo(m, SERVER, kit.Select(ice.Info.HostName, m.Option("nodename"))); m.Option(tcp.PORT) == tcp.RANDOM {
|
||||||
m.Option(tcp.PORT, m.Cmdx(tcp.PORT, aaa.RIGHT))
|
m.Option(tcp.PORT, m.Cmdx(tcp.PORT, aaa.RIGHT))
|
||||||
}
|
}
|
||||||
|
aaa.UserRoot(m, m.Option(aaa.PASSWORD), m.Option(aaa.USERNAME), m.Option(aaa.USERROLE))
|
||||||
|
|
||||||
m.Target().Start(m, m.OptionSimple(mdb.NAME, tcp.HOST, tcp.PORT)...)
|
m.Target().Start(m, m.OptionSimple(mdb.NAME, tcp.HOST, tcp.PORT)...)
|
||||||
m.Sleep300ms()
|
m.Sleep300ms()
|
||||||
|
@ -22,11 +22,6 @@ func init() {
|
|||||||
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
||||||
}},
|
}},
|
||||||
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer m.ProcessInner()
|
|
||||||
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO); !cli.IsSuccess(msg) {
|
|
||||||
_inner_make(m, msg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN); !cli.IsSuccess(msg) {
|
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN); !cli.IsSuccess(msg) {
|
||||||
_inner_make(m, msg)
|
_inner_make(m, msg)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user