mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +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) {
|
||||
m.Option(ice.MSG_USERROLE, ROOT)
|
||||
m.Option(ice.MSG_USERNAME, ice.Info.UserName)
|
||||
func UserRoot(m *ice.Message, arg ...string) { // password username userrole
|
||||
userrole := kit.Select(ice.Info.UserName, arg, 2)
|
||||
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) {
|
||||
_user_create(m, ROOT, ice.Info.UserName, "")
|
||||
if !_user_exists(m, username) {
|
||||
_user_create(m, userrole, username, kit.Select("", arg, 0))
|
||||
}
|
||||
}
|
||||
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
|
||||
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())
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
@ -63,7 +64,7 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) {
|
||||
defer func() {
|
||||
m.Push(CMD_OUT, out.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
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ func CookieName(url string) string {
|
||||
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)))
|
||||
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) {
|
||||
if mime != "" {
|
||||
|
@ -284,10 +284,11 @@ func init() {
|
||||
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 {
|
||||
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.Sleep300ms()
|
||||
|
@ -22,11 +22,6 @@ func init() {
|
||||
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
||||
}},
|
||||
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) {
|
||||
_inner_make(m, msg)
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user