1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-03-10 10:52:21 +08:00
parent cae65f34e8
commit 564d320c7e
3 changed files with 22 additions and 16 deletions

View File

@ -145,6 +145,8 @@ const (
SH = "sh" SH = "sh"
GO = "go" GO = "go"
GIT = "git" GIT = "git"
WGET = "wget"
CURL = "curl"
MAN = "man" MAN = "man"
RUN = "run" RUN = "run"
KILL = "kill" KILL = "kill"

View File

@ -253,8 +253,8 @@ func init() {
} }
} }
}}, }},
PROXY_CONF: {Name: "proxyConf name* port path", Hand: func(m *ice.Message, arg ...string) { PROXY_CONF: {Name: "proxyConf name* port host path", Hand: func(m *ice.Message, arg ...string) {
if dir := m.OptionDefault(nfs.PATH, PROXY_PATH); nfs.Exists(m, dir) { if dir := m.OptionDefault(nfs.PATH, PROXY_PATH, tcp.HOST, "127.0.0.1"); nfs.Exists(m, dir) {
for _, p := range []string{"server.conf", "location.conf", "upstream.conf"} { for _, p := range []string{"server.conf", "location.conf", "upstream.conf"} {
m.Cmd(nfs.SAVE, kit.Format("%s/conf/portal/%s/%s", dir, m.Option(mdb.NAME), p), m.Template(p)+lex.NL) m.Cmd(nfs.SAVE, kit.Format("%s/conf/portal/%s/%s", dir, m.Option(mdb.NAME), p), m.Template(p)+lex.NL)
} }

View File

@ -45,32 +45,36 @@ func _publish_file(m *ice.Message, file string, arg ...string) string {
return m.Cmdx(nfs.LINK, path.Join(ice.USR_PUBLISH, kit.Select(path.Base(file), arg, 0)), file) return m.Cmdx(nfs.LINK, path.Join(ice.USR_PUBLISH, kit.Select(path.Base(file), arg, 0)), file)
} }
func _publish_contexts(m *ice.Message, arg ...string) { func _publish_contexts(m *ice.Message, arg ...string) {
m.Options(nfs.DIR_ROOT, "").OptionDefault(ice.MSG_USERNAME, "demo") m.Options(nfs.DIR_ROOT, "").OptionDefault(ice.MSG_USERNAME, ice.DEMO)
m.Option("tcp_localhost", strings.ToLower(ice.Info.Hostname))
host := tcp.PublishLocalhost(m, web.UserHost(m)) host := tcp.PublishLocalhost(m, web.UserHost(m))
m.Option(ice.TCP_DOMAIN, kit.ParseURL(host).Hostname())
m.Option("tcp_localhost", strings.ToLower(ice.Info.Hostname))
m.OptionDefault(web.DOMAIN, host)
env := []string{}
kit.If(m.Option("ctx_dev_ip"), func(p string) { env = append(env, "ctx_dev_ip", p) })
kit.If(m.Option(ice.MSG_USERPOD), func(p string) { env = append(env, cli.CTX_POD, p) })
kit.If(len(env) > 0, func() { m.Options(cli.CTX_ENV, lex.SP+kit.JoinKV(mdb.EQ, lex.SP, env...)) })
m.OptionDefault("ctx_cli", "temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp")
m.OptionDefault("ctx_arg", kit.JoinCmds(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK)))
for _, k := range kit.Default(arg, ice.MISC) { for _, k := range kit.Default(arg, ice.MISC) {
m.OptionDefault(web.DOMAIN, host)
m.Options(cli.CTX_ENV, kit.Select("", lex.SP+kit.JoinKV(mdb.EQ, lex.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
kit.If(m.Option("ctx_dev_ip"), func(p string) {
m.Option(cli.CTX_ENV, m.Option(cli.CTX_ENV)+" "+"ctx_dev_ip="+tcp.PublishLocalhost(m, p))
})
m.Option(ice.TCP_DOMAIN, kit.ParseURL(host).Hostname())
switch k { switch k {
case INSTALL: case INSTALL:
m.Option("format", "raw") m.Option("format", "raw")
case ice.BASE: case ice.BASE:
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.SHY).Append(web.CLIENT_ORIGIN)) m.Option(web.DOMAIN, web.SpideOrigin(m, ice.SHY))
case ice.CORE: case ice.CORE:
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.DEV).Append(web.CLIENT_ORIGIN)) m.Option(web.DOMAIN, web.SpideOrigin(m, ice.DEV))
case nfs.SOURCE, ice.DEV: case nfs.SOURCE, ice.DEV:
m.OptionDefault(nfs.SOURCE, ice.Info.Make.Remote) m.OptionDefault(nfs.SOURCE, ice.Info.Make.Remote)
case nfs.BINARY, ice.APP: case nfs.BINARY, ice.APP:
case "curl", "wget": case cli.CURL, cli.WGET:
case "manual": case "manual":
m.Options(nfs.BINARY, "ice.linux.amd64") m.Option(nfs.BINARY, "ice.linux.amd64")
} }
template := strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))) if template := strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))); m.Option("format") == "raw" {
if m.Option("format") == "raw" {
m.Echo(template) m.Echo(template)
} else { } else {
m.EchoScript(template) m.EchoScript(template)