forked from x/icebergs
add some
This commit is contained in:
parent
8f44941f25
commit
76a8c812b2
@ -148,17 +148,21 @@ const (
|
|||||||
TZ = "TZ"
|
TZ = "TZ"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
CTX_SHY = "ctx_shy"
|
CTX_SHY = "ctx_shy"
|
||||||
CTX_DEV = "ctx_dev"
|
CTX_DEV = "ctx_dev"
|
||||||
CTX_OPS = "ctx_ops"
|
CTX_DEV_IP = "ctx_dev_ip"
|
||||||
CTX_DEMO = "ctx_demo"
|
CTX_REPOS = "ctx_repos"
|
||||||
CTX_MAIL = "ctx_mail"
|
CTX_OPS = "ctx_ops"
|
||||||
CTX_ROOT = "ctx_root"
|
CTX_DEMO = "ctx_demo"
|
||||||
|
CTX_MAIL = "ctx_mail"
|
||||||
|
CTX_ROOT = "ctx_root"
|
||||||
|
|
||||||
CTX_PID = "ctx_pid"
|
CTX_PID = "ctx_pid"
|
||||||
CTX_LOG = "ctx_log"
|
CTX_LOG = "ctx_log"
|
||||||
CTX_POD = "ctx_pod"
|
CTX_POD = "ctx_pod"
|
||||||
CTX_ENV = "ctx_env"
|
CTX_ENV = "ctx_env"
|
||||||
|
CTX_CLI = "ctx_cli"
|
||||||
|
CTX_ARG = "ctx_arg"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ENV_LIST = []string{TZ, LANG, TERM, SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_DEMO, CTX_MAIL, CTX_ROOT, CTX_PID}
|
var ENV_LIST = []string{TZ, LANG, TERM, SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_DEMO, CTX_MAIL, CTX_ROOT, CTX_PID}
|
||||||
|
@ -39,14 +39,13 @@ func init() {
|
|||||||
func init() { ice.Info.Template = Template }
|
func init() { ice.Info.Template = Template }
|
||||||
|
|
||||||
func Template(m *ice.Message, p string, data ...ice.Any) string {
|
func Template(m *ice.Message, p string, data ...ice.Any) string {
|
||||||
text := TemplateText(m, p)
|
if text := TemplateText(m, p); text == "" {
|
||||||
if text == "" {
|
|
||||||
return ""
|
return ""
|
||||||
}
|
} else if len(data) == 0 {
|
||||||
if len(data) == 0 {
|
|
||||||
return kit.Renders(text, m)
|
return kit.Renders(text, m)
|
||||||
|
} else {
|
||||||
|
return kit.Renders(text, data[0])
|
||||||
}
|
}
|
||||||
return kit.Renders(text, data[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var TemplateText = func(m *ice.Message, p string) string {
|
var TemplateText = func(m *ice.Message, p string) string {
|
||||||
|
@ -45,44 +45,35 @@ 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, ice.DEMO)
|
m.Options(nfs.DIR_ROOT, "")
|
||||||
|
m.OptionDefault(web.DOMAIN, tcp.PublishLocalhost(m, web.UserHost(m)))
|
||||||
host := tcp.PublishLocalhost(m, web.UserHost(m))
|
m.OptionDefault(cli.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.Option(ice.TCP_DOMAIN, kit.ParseURL(host).Hostname())
|
m.OptionDefault(cli.CTX_ARG, kit.JoinCmds(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE)))
|
||||||
m.Option("tcp_localhost", strings.ToLower(ice.Info.Hostname))
|
|
||||||
m.OptionDefault(web.DOMAIN, host)
|
|
||||||
|
|
||||||
env := []string{}
|
|
||||||
// m.Option("ctx_dev_ip", tcp.PublishLocalhost(m, web.SpideOrigin(m, ice.OPS)))
|
|
||||||
m.Option("ctx_dev_ip", web.HostPort(m, web.AdminCmd(m, tcp.HOST).Append(aaa.IP), web.AdminCmd(m, web.SERVE).Append(tcp.PORT)))
|
|
||||||
// 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),
|
|
||||||
aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE),
|
|
||||||
))
|
|
||||||
|
|
||||||
for _, k := range kit.Default(arg, ice.MISC) {
|
for _, k := range kit.Default(arg, ice.MISC) {
|
||||||
|
env := []string{}
|
||||||
switch k {
|
switch k {
|
||||||
case INSTALL:
|
|
||||||
m.Option("format", "raw")
|
|
||||||
case ice.BASE:
|
|
||||||
m.Option(web.DOMAIN, web.SpideOrigin(m, ice.SHY))
|
|
||||||
case ice.CORE:
|
|
||||||
m.Option(web.DOMAIN, web.SpideOrigin(m, ice.DEV))
|
|
||||||
case nfs.SOURCE, ice.DEV:
|
case nfs.SOURCE, ice.DEV:
|
||||||
if m.Option(ice.MSG_USERPOD) == "" {
|
if ice.Info.NodeType == web.SERVER {
|
||||||
|
m.Options(nfs.SOURCE, ice.Info.Make.Remote)
|
||||||
|
} else if m.Option(ice.MSG_USERPOD) == "" {
|
||||||
m.Option(nfs.SOURCE, web.AdminCmd(m, cli.RUNTIME, "make.remote").Result())
|
m.Option(nfs.SOURCE, web.AdminCmd(m, cli.RUNTIME, "make.remote").Result())
|
||||||
} else {
|
} else {
|
||||||
m.Option(nfs.SOURCE, web.AdminCmd(m, web.SPACE, m.Option(ice.MSG_USERPOD), cli.RUNTIME, "make.remote").Result())
|
m.Option(nfs.SOURCE, web.AdminCmd(m, web.SPACE, kit.KeyBase(m.Option(ice.MSG_USERPOD)), cli.RUNTIME, "make.remote").Result())
|
||||||
}
|
}
|
||||||
|
env = append(env, cli.CTX_REPOS, m.Option(nfs.SOURCE))
|
||||||
|
fallthrough
|
||||||
case nfs.BINARY, ice.APP:
|
case nfs.BINARY, ice.APP:
|
||||||
|
if host := web.HostPort(m, web.AdminCmd(m, tcp.HOST).Append(aaa.IP), web.AdminCmd(m, web.SERVE).Append(tcp.PORT)); m.Option(web.DOMAIN) != host {
|
||||||
|
env = append(env, cli.CTX_DEV_IP, host)
|
||||||
|
}
|
||||||
|
if ice.Info.NodeType == web.WORKER && m.Option(ice.MSG_USERPOD) != "" {
|
||||||
|
env = append(env, cli.CTX_POD, m.Option(ice.MSG_USERPOD))
|
||||||
|
} else if name := web.AdminCmd(m, cli.RUNTIME, "boot.pathname").Result(); !kit.IsIn(name, path.Base(m.Option(nfs.SOURCE)), ice.CONTEXTS) {
|
||||||
|
env = append(env, "ctx_name", name)
|
||||||
|
}
|
||||||
case cli.CURL, cli.WGET:
|
case cli.CURL, cli.WGET:
|
||||||
case "manual":
|
|
||||||
m.Option(nfs.BINARY, "ice.linux.amd64")
|
|
||||||
}
|
}
|
||||||
|
kit.If(len(env) > 0, func() { m.Options(cli.CTX_ENV, lex.SP+kit.JoinKV(mdb.EQ, lex.SP, env...)) })
|
||||||
if template := strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))); m.Option("format") == "raw" {
|
if template := strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))); m.Option("format") == "raw" {
|
||||||
m.Echo(template)
|
m.Echo(template)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user