mirror of
https://shylinux.com/x/icebergs
synced 2025-05-02 19:47:02 +08:00
opt some
This commit is contained in:
parent
fc55214a38
commit
3c40de3c1c
@ -204,6 +204,13 @@ func init() {
|
||||
}
|
||||
m.Sort(nfs.PATH)
|
||||
}},
|
||||
"make.domain": {Name: "make.domain", Help: "接口命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
if os.Getenv("ctx_dev") == "" || os.Getenv("ctx_pod") == "" {
|
||||
m.Echo(m.Conf(RUNTIME, "make.domain"))
|
||||
} else {
|
||||
m.Echo(kit.MergePOD(os.Getenv("ctx_dev"), os.Getenv("ctx_pod")))
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == BOOTINFO {
|
||||
arg = arg[1:]
|
||||
|
@ -92,7 +92,7 @@ func _space_handle(m *ice.Message, safe bool, send map[string]*ice.Message, c *w
|
||||
msg.Log("recv", "%v->%v %s %v", source, target, msg.Detailv(), msg.FormatMeta())
|
||||
|
||||
if len(target) == 0 {
|
||||
msg.Log_AUTH(aaa.USERROLE, msg.Option(ice.MSG_USERROLE), aaa.USERNAME, msg.Option(ice.MSG_USERNAME))
|
||||
msg.Log_AUTH(aaa.USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), m.Cmd(aaa.USER, msg.Option(ice.MSG_USERNAME)).Append(aaa.USERROLE)), aaa.USERNAME, msg.Option(ice.MSG_USERNAME))
|
||||
if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令
|
||||
msg.Go(func() { _space_exec(msg, source, target, c, name) })
|
||||
} else { // 上行请求
|
||||
|
@ -8,6 +8,8 @@ import (
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
@ -123,6 +125,15 @@ func init() {
|
||||
_header_users(m, m.ActionKey(), arg...)
|
||||
}},
|
||||
|
||||
"local": {Name: "local", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
||||
pod := strings.Split(m.Cmdx(web.SPACE, m.Option(ice.MSG_USERPOD), cli.RUNTIME, "make.domain"), "/chat/pod/")[1]
|
||||
m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), nfs.SAVE, "etc/local.shy", m.Cmdx(web.SPACE, pod, nfs.CAT, "etc/local.shy"))
|
||||
m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), ssh.SOURCE, "etc/local.shy")
|
||||
}},
|
||||
aaa.INVITE: {Name: "invite", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.CORE)
|
||||
m.Cmd(code.PUBLISH, mdb.CREATE, nfs.FILE, ice.BIN_ICE_BIN)
|
||||
}},
|
||||
code.WEBPACK: {Name: "webpack", Help: "打包页面", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.WEBPACK, cli.BUILD, m.OptionSimple(mdb.NAME))
|
||||
}},
|
||||
|
@ -115,6 +115,7 @@ func _autogen_git(m *ice.Message, arg ...string) map[string]interface{} {
|
||||
"Remote", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "config", "remote.origin.url")),
|
||||
"Branch", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "rev-parse", "--abbrev-ref", "HEAD")),
|
||||
"Version", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "describe", "--tags")),
|
||||
"Domain", m.Option(ice.MSG_USERWEB),
|
||||
)
|
||||
}
|
||||
func _autogen_gits(m *ice.Message, arg ...string) string {
|
||||
@ -199,6 +200,7 @@ func init() {
|
||||
m.Cmdy(nfs.DIR, "usr/release/binpack.go")
|
||||
m.Cmdy(nfs.DIR, "usr/release/conf.go")
|
||||
}
|
||||
m.Cmdy(nfs.CAT, "src/version.go")
|
||||
}},
|
||||
RELAY: {Name: "relay alias username host port list", Help: "跳板", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(COMPILE, RELAY)
|
||||
|
@ -75,109 +75,119 @@ func _binpack_ctx(m *ice.Message, f *os.File) {
|
||||
const BINPACK = "binpack"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.FileExists(path.Join(ice.USR_VOLCANOS, ice.PROTO_JS)) {
|
||||
m.Cmd(BINPACK, mdb.REMOVE)
|
||||
} else {
|
||||
ice.Info.Dump = func(w io.Writer, name string, cb func(string)) bool {
|
||||
for _, key := range []string{name, strings.TrimPrefix(name, ice.USR_VOLCANOS)} {
|
||||
if b, ok := ice.Info.Pack[key]; ok {
|
||||
if cb != nil {
|
||||
cb(name)
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
BINPACK: {Name: "binpack", Help: "打包", Value: kit.Data(mdb.SHORT, "path", mdb.FIELD, "time,path")},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.FileExists(path.Join(ice.USR_VOLCANOS, ice.PROTO_JS)) {
|
||||
m.Cmd(BINPACK, mdb.REMOVE)
|
||||
} else {
|
||||
ice.Info.Dump = func(w io.Writer, name string, cb func(string)) bool {
|
||||
for _, key := range []string{name, strings.TrimPrefix(name, ice.USR_VOLCANOS)} {
|
||||
if b, ok := ice.Info.Pack[key]; ok {
|
||||
if cb != nil {
|
||||
cb(name)
|
||||
}
|
||||
w.Write(b)
|
||||
return true // 打包文件
|
||||
}
|
||||
w.Write(b)
|
||||
}
|
||||
return false
|
||||
}
|
||||
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||
if ice.Info.Dump(w, r.URL.Path, func(name string) { web.RenderType(w, name, "") }) {
|
||||
return true // 打包文件
|
||||
}
|
||||
}
|
||||
return false
|
||||
return false
|
||||
})
|
||||
}
|
||||
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||
if ice.Info.Dump(w, r.URL.Path, func(name string) { web.RenderType(w, name, "") }) {
|
||||
return true // 打包文件
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
nfs.AddRewrite(func(msg *ice.Message, name string) []byte {
|
||||
if strings.HasPrefix(name, ice.SRC) && kit.FileExists(name) {
|
||||
nfs.AddRewrite(func(msg *ice.Message, name string) []byte {
|
||||
if strings.HasPrefix(name, ice.SRC) && kit.FileExists(name) {
|
||||
return nil
|
||||
}
|
||||
if b, ok := ice.Info.Pack[name]; ok {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
if b, ok := ice.Info.Pack[path.Join(m.Option(nfs.DIR_ROOT), name)]; ok && len(b) > 0 {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
if b, ok := ice.Info.Pack[strings.TrimPrefix(name, ice.USR_VOLCANOS)]; ok && len(b) > 0 {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
if b, ok := ice.Info.Pack[path.Join(ice.PS, name)]; ok && len(b) > 0 {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if b, ok := ice.Info.Pack[name]; ok {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
if b, ok := ice.Info.Pack[path.Join(m.Option(nfs.DIR_ROOT), name)]; ok && len(b) > 0 {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
if b, ok := ice.Info.Pack[strings.TrimPrefix(name, ice.USR_VOLCANOS)]; ok && len(b) > 0 {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
if b, ok := ice.Info.Pack[path.Join(ice.PS, name)]; ok && len(b) > 0 {
|
||||
m.Logs(BINPACK, len(b), name)
|
||||
return b
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}},
|
||||
mdb.CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
if f, p, e := kit.Create(ice.SRC_BINPACK_GO); m.Assert(e) {
|
||||
defer f.Close()
|
||||
defer m.Echo(p)
|
||||
})
|
||||
}},
|
||||
mdb.CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
if f, p, e := kit.Create(ice.SRC_BINPACK_GO); m.Assert(e) {
|
||||
defer f.Close()
|
||||
defer m.Echo(p)
|
||||
|
||||
fmt.Fprintln(f, `package main`)
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, `import (`)
|
||||
fmt.Fprintln(f, ` ice "shylinux.com/x/icebergs"`)
|
||||
fmt.Fprintln(f, `)`)
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, `package main`)
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, `import (`)
|
||||
fmt.Fprintln(f, ` ice "shylinux.com/x/icebergs"`)
|
||||
fmt.Fprintln(f, `)`)
|
||||
fmt.Fprintln(f)
|
||||
|
||||
fmt.Fprintln(f, `func init() {`)
|
||||
defer fmt.Fprintln(f, `}`)
|
||||
fmt.Fprintln(f, `func init() {`)
|
||||
defer fmt.Fprintln(f, `}`)
|
||||
|
||||
if kit.FileExists(ice.USR_VOLCANOS) && kit.FileExists(ice.USR_INTSHELL) && m.Option(ice.MSG_USERPOD) == "" {
|
||||
fmt.Fprintln(f, ` ice.Info.Pack = map[string][]byte{`)
|
||||
_binpack_can(m, f, ice.USR_VOLCANOS)
|
||||
_binpack_dir(m, f, ice.USR_INTSHELL)
|
||||
if kit.FileExists(ice.USR_VOLCANOS) && kit.FileExists(ice.USR_INTSHELL) && m.Option(ice.MSG_USERPOD) == "" {
|
||||
fmt.Fprintln(f, ` ice.Info.Pack = map[string][]byte{`)
|
||||
_binpack_can(m, f, ice.USR_VOLCANOS)
|
||||
_binpack_dir(m, f, ice.USR_INTSHELL)
|
||||
fmt.Fprintln(f, ` }`)
|
||||
}
|
||||
|
||||
fmt.Fprintln(f, ` pack := map[string][]byte{`)
|
||||
_binpack_ctx(m, f)
|
||||
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(nfs.PATH)).Table(func(index int, value map[string]string, head []string) {
|
||||
_binpack_dir(m, f, value[nfs.PATH])
|
||||
})
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_INIT_SHY))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_EXIT_SHY))
|
||||
fmt.Fprintln(f, ` }`)
|
||||
}
|
||||
|
||||
fmt.Fprintln(f, ` pack := map[string][]byte{`)
|
||||
_binpack_ctx(m, f)
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_INIT_SHY))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_EXIT_SHY))
|
||||
fmt.Fprintln(f, ` }`)
|
||||
fmt.Fprintln(f, `
|
||||
fmt.Fprintln(f, `
|
||||
for k, v := range pack {
|
||||
ice.Info.Pack[k] = v
|
||||
}
|
||||
`)
|
||||
}
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
ice.Info.Pack = map[string][]byte{}
|
||||
}},
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
for key, value := range ice.Info.Pack {
|
||||
if strings.HasPrefix(key, ice.PS) {
|
||||
key = ice.USR_VOLCANOS + key
|
||||
}
|
||||
m.Log_EXPORT(nfs.FILE, kit.WriteFile(key, value), nfs.SIZE, len(value))
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, nfs.PATH, arg[0])
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
ice.Info.Pack = map[string][]byte{}
|
||||
}},
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
for key, value := range ice.Info.Pack {
|
||||
if strings.HasPrefix(key, ice.PS) {
|
||||
key = ice.USR_VOLCANOS + key
|
||||
}
|
||||
m.Log_EXPORT(nfs.FILE, kit.WriteFile(key, value), nfs.SIZE, len(value))
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
for k, v := range ice.Info.Pack {
|
||||
m.Push(nfs.PATH, k).Push(nfs.SIZE, len(v))
|
||||
}
|
||||
m.Sort(nfs.PATH)
|
||||
return
|
||||
}
|
||||
m.Echo(string(ice.Info.Pack[arg[0]]))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
for k, v := range ice.Info.Pack {
|
||||
m.Push(nfs.PATH, k).Push(nfs.SIZE, len(v))
|
||||
}
|
||||
m.Sort(nfs.PATH)
|
||||
return
|
||||
}
|
||||
m.Echo(string(ice.Info.Pack[arg[0]]))
|
||||
}},
|
||||
}})
|
||||
}})
|
||||
}
|
||||
|
1
info.go
1
info.go
@ -15,6 +15,7 @@ type MakeInfo struct {
|
||||
Module string
|
||||
Remote string
|
||||
Branch string
|
||||
Domain string
|
||||
Version string
|
||||
HostName string
|
||||
UserName string
|
||||
|
@ -64,11 +64,11 @@ func init() {
|
||||
m.Option(mdb.NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(REPOS)), ".git"), m.Option(mdb.NAME)))
|
||||
m.Option(nfs.PATH, kit.Select(path.Join(ice.USR, m.Option(mdb.NAME)), m.Option(nfs.PATH)))
|
||||
m.Option(REPOS, kit.Select(m.Config(REPOS)+ice.PS+m.Option(mdb.NAME), m.Option(REPOS)))
|
||||
if strings.Contains(m.Option(REPOS), "@") {
|
||||
ls := strings.Split(m.Option(REPOS), "@")
|
||||
m.Option(REPOS, ls[0])
|
||||
m.Option(BRANCH, ls[1])
|
||||
}
|
||||
// if strings.Contains(m.Option(REPOS), "@") {
|
||||
// ls := strings.Split(m.Option(REPOS), "@")
|
||||
// m.Option(REPOS, ls[0])
|
||||
// m.Option(BRANCH, ls[1])
|
||||
// }
|
||||
|
||||
_repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH))
|
||||
if s, e := os.Stat(path.Join(m.Option(nfs.PATH), ".git")); e == nil && s.IsDir() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user