1
0
forked from x/icebergs
This commit is contained in:
harveyshao 2022-08-28 20:35:26 +08:00
parent d8310d576b
commit 4c981b2236
10 changed files with 51 additions and 18 deletions

View File

@ -71,3 +71,12 @@ func IsCentos(m *ice.Message, arg ...string) bool {
} }
return false return false
} }
func IsUbuntu(m *ice.Message, arg ...string) bool {
if strings.Contains(m.Conf(RUNTIME, kit.Keys(HOST, OSID)), UBUNTU) {
if len(arg) > 0 {
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, UBUNTU, CMD, "yum install -y "+kit.Select(arg[0], arg, 1))
}
return true
}
return false
}

View File

@ -143,7 +143,9 @@ func _hash_import(m *ice.Message, prefix, chain, file string) {
defer Lock(m, prefix, chain)() defer Lock(m, prefix, chain)()
f, e := miss.OpenFile(kit.Keys(file, JSON)) f, e := miss.OpenFile(kit.Keys(file, JSON))
m.Assert(e) if m.Warn(e) {
return
}
defer f.Close() defer f.Close()
list := Map{} list := Map{}
@ -279,17 +281,20 @@ func HashTarget(m *ice.Message, h string, add Any) (p Any) {
if pp, ok := p.(Map); ok && len(pp) == 0 { if pp, ok := p.(Map); ok && len(pp) == 0 {
p = nil p = nil
} }
m.Debug("what %v", p)
if p == nil && add != nil { if p == nil && add != nil {
switch add := add.(type) { switch add := add.(type) {
case func(ice.Map) ice.Any: case func(ice.Map) ice.Any:
p = add(value) p = add(value)
case func() ice.Any: case func() ice.Any:
p = add() p = add()
m.Debug("what %v", p)
default: default:
m.ErrorNotImplement(p) m.ErrorNotImplement(p)
return return
} }
value[TARGET] = p value[TARGET] = p
m.Debug("what %v", p)
} }
}) })
return return

View File

@ -41,7 +41,7 @@ func _cat_list(m *ice.Message, name string) {
return // 没有权限 return // 没有权限
} }
f, e := _cat_find(m, name) f, e := _cat_find(m, name)
if m.Warn(e, ice.ErrNotFound, name) { if m.Warn(e) {
return // 没有文件 return // 没有文件
} }
defer f.Close() defer f.Close()

View File

@ -89,7 +89,7 @@ func (f *Frame) alias(m *ice.Message, ls []string) []string {
} }
return ls return ls
} }
func (f *Frame) parse(m *ice.Message, line string) string { func (f *Frame) parse(m *ice.Message, h, line string) string {
msg := m.Spawn(f.target) msg := m.Spawn(f.target)
ls := f.change(msg, f.alias(msg, kit.Split(strings.TrimSpace(line)))) ls := f.change(msg, f.alias(msg, kit.Split(strings.TrimSpace(line))))
if len(ls) == 0 { if len(ls) == 0 {
@ -97,7 +97,7 @@ func (f *Frame) parse(m *ice.Message, line string) string {
} }
msg.Render("", kit.List()) msg.Render("", kit.List())
if msg.Cmdy(ls); msg.IsErrNotFound() { if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFound() {
msg.SetResult().Cmdy(cli.SYSTEM, ls) msg.SetResult().Cmdy(cli.SYSTEM, ls)
} }
@ -111,7 +111,7 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
if m.I, m.O = f.stdin, f.stdout; h == STDIO { if m.I, m.O = f.stdin, f.stdout; h == STDIO {
gdb.Event(m, SOURCE_STDIO) gdb.Event(m, SOURCE_STDIO)
m.Sleep("2.1s") m.Sleep("3s")
} }
bio := bufio.NewScanner(f.stdin) bio := bufio.NewScanner(f.stdin)
@ -141,7 +141,7 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
f.printf(m, "\033[0m") // 清空格式 f.printf(m, "\033[0m") // 清空格式
} }
} }
line = f.parse(m, line) line = f.parse(m, h, line)
} }
return f return f
} }

View File

@ -240,6 +240,12 @@ func init() {
m.Cmd(mdb.RENDER, mdb.CREATE, k, m.Prefix(k)) m.Cmd(mdb.RENDER, mdb.CREATE, k, m.Prefix(k))
m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k)) m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k))
} }
m.Go(func() {
m.Sleep300ms()
cli.IsAlpine(m, GO)
cli.IsCentos(m, GO)
cli.IsUbuntu(m, GO, "golang")
})
}}, }},
GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeActions(ice.Actions{ GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeActions(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {

View File

@ -13,6 +13,7 @@ import (
"shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/gdb"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/tcp"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
) )
@ -67,8 +68,8 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH)
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey()) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())
m.Config(ice.CONTEXTS, _contexts)
gdb.Watch(m, web.SERVE_START, m.PrefixKey()) gdb.Watch(m, web.SERVE_START, m.PrefixKey())
m.Config(ice.CONTEXTS, _contexts)
}}, }},
web.SERVE_START: {Name: "serve.start", Help: "服务启动", Hand: func(m *ice.Message, arg ...string) { web.SERVE_START: {Name: "serve.start", Help: "服务启动", Hand: func(m *ice.Message, arg ...string) {
_publish_file(m, ice.ICE_BIN) _publish_file(m, ice.ICE_BIN)
@ -88,8 +89,12 @@ func init() {
}}, }},
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) { ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
u := web.OptionUserWeb(m) u := web.OptionUserWeb(m)
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(u.Host, ice.DF)[0], host := strings.Split(u.Host, ice.DF)[0]
kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1))) if host == tcp.LOCALHOST {
host = m.Cmd(tcp.HOST).Append(aaa.IP)
}
m.Option("ctx_env", kit.Select("", " "+kit.JoinKV("=", " ", "ctx_pod", m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
if len(arg) == 0 { if len(arg) == 0 {
arg = append(arg, ice.MISC, ice.CORE, ice.BASE) arg = append(arg, ice.MISC, ice.CORE, ice.BASE)
@ -158,15 +163,15 @@ func init() {
} }
var _contexts = kit.Dict( var _contexts = kit.Dict(
ice.MISC, `# 下载命令 ice.MISC, `# 下载命令 curl wget
export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app username {{.Option "user.name"}} export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}
export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}} export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}
`, `,
ice.CORE, `# 克隆源码 ice.CORE, `# 下载工具 curl wget
git clone {{.Option "remote"}}; cd {{.Option "pathname"}} && source etc/miss.sh port 9020
`,
ice.BASE, `# 下载工具
ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL {{.Cmdx "spide" "shy" "client.url"}}; source $ctx_temp binary ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL {{.Cmdx "spide" "shy" "client.url"}}; source $ctx_temp binary
ctx_temp=$(mktemp); wget -O $ctx_temp -q {{.Cmdx "spide" "shy" "client.url"}}; source $ctx_temp binary ctx_temp=$(mktemp); wget -O $ctx_temp -q {{.Cmdx "spide" "shy" "client.url"}}; source $ctx_temp binary
`,
ice.BASE, `# 下载源码
git clone {{.Option "remote"}}; cd {{.Option "pathname"}} && source etc/miss.sh
`, `,
) )

View File

@ -25,7 +25,9 @@ func _xterm_socket(m *ice.Message, h, t string) {
} }
func _xterm_get(m *ice.Message, h string, must bool) *os.File { func _xterm_get(m *ice.Message, h string, must bool) *os.File {
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE) t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
m.Debug("what %v", h)
if f, ok := mdb.HashTarget(m, h, func() ice.Any { if f, ok := mdb.HashTarget(m, h, func() ice.Any {
m.Debug("what %v", h)
if !must { if !must {
return nil return nil
} }

View File

@ -49,7 +49,12 @@ func init() {
m.Conf(REPOS, mdb.HASH, "") m.Conf(REPOS, mdb.HASH, "")
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd()) _repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
m.Cmd(nfs.DIR, ice.USR, "name,path", func(value ice.Maps) { _repos_insert(m, value[mdb.NAME], value[nfs.PATH]) }) m.Cmd(nfs.DIR, ice.USR, "name,path", func(value ice.Maps) { _repos_insert(m, value[mdb.NAME], value[nfs.PATH]) })
m.Go(func() { m.Sleep300ms(); cli.IsAlpine(m, GIT) }) m.Go(func() {
m.Sleep300ms()
cli.IsAlpine(m, GIT)
cli.IsCentos(m, GIT)
cli.IsUbuntu(m, GIT)
})
m.Config(REPOS, "https://shylinux.com/x") m.Config(REPOS, "https://shylinux.com/x")
}}, }},
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) { mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {

View File

@ -34,7 +34,7 @@ type input struct {
} }
func (s input) Load(m *ice.Message, arg ...string) { func (s input) Load(m *ice.Message, arg ...string) {
if f, e := nfs.OpenFile(m.Message, m.Option(nfs.FILE)); m.Assert(e) { if f, e := nfs.OpenFile(m.Message, m.Option(nfs.FILE)); !m.Warn(e) {
defer f.Close() defer f.Close()
// 清空数据 // 清空数据

View File

@ -14,6 +14,7 @@ type compile struct {
ice.Code ice.Code
regexp string `data:".*.js"` regexp string `data:".*.js"`
linux string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz"` linux string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz"`
darwin string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-darwin-x64.tar.gz"`
list string `name:"list path auto xterm listScript order install" help:"编译器"` list string `name:"list path auto xterm listScript order install" help:"编译器"`
} }