mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
803a04bbe5
commit
16678e04c8
@ -43,9 +43,32 @@ func _dream_show(m *ice.Message, name string) {
|
||||
m.Cmd("web.code.git.repos", mdb.CREATE, kit.SSH_REPOS, m.Option(kit.SSH_REPOS), kit.MDB_PATH, p)
|
||||
}
|
||||
|
||||
if m.Option("template") != "" {
|
||||
for _, file := range []string{"etc/miss.sh", "go.mod", "src/main.go", "src/main.shy"} {
|
||||
if _, e := os.Stat(path.Join(p, file)); os.IsNotExist(e) {
|
||||
m.Cmdy(nfs.COPY, path.Join(p, file), path.Join(m.Option("template"), file))
|
||||
switch file {
|
||||
case "go.mod":
|
||||
kit.Rewrite(path.Join(p, file), func(line string) string {
|
||||
if strings.HasPrefix(line, "module") {
|
||||
m.Info("module %s", name)
|
||||
return "module " + name
|
||||
}
|
||||
return line
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
m.Option(cli.CMD_DIR, p)
|
||||
m.Cmd(cli.SYSTEM, "bash", "-c", "source etc/miss.sh")
|
||||
}()
|
||||
}
|
||||
|
||||
// 任务脚本
|
||||
miss := path.Join(p, "etc/miss.sh")
|
||||
if _, e := os.Stat(miss); e != nil {
|
||||
if _, e := os.Stat(miss); os.IsNotExist(e) {
|
||||
m.Cmd(nfs.SAVE, miss, m.Conf(DREAM, "meta.miss"))
|
||||
}
|
||||
|
||||
@ -57,7 +80,7 @@ func _dream_show(m *ice.Message, name string) {
|
||||
}
|
||||
|
||||
if m.Richs(SPACE, nil, name, nil) == nil {
|
||||
m.Optionv(cli.CMD_DIR, p)
|
||||
m.Option(cli.CMD_DIR, p)
|
||||
m.Optionv(cli.CMD_ENV, kit.Simple(
|
||||
"ctx_dev", m.Conf(cli.RUNTIME, "conf.ctx_dev"),
|
||||
"PATH", kit.Path(path.Join(p, "bin"))+":"+kit.Path("bin")+":"+os.Getenv("PATH"),
|
||||
|
@ -71,17 +71,12 @@ func init() {
|
||||
}
|
||||
|
||||
switch arg[0] {
|
||||
case "cmd":
|
||||
m.Cmdy(SPACE, m.Option(ROUTE), ctx.COMMAND)
|
||||
case "name":
|
||||
m.Cmdy(SPACE, m.Option(ROUTE), DREAM)
|
||||
case "template":
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Cmdy(nfs.DIR, "usr/icebergs")
|
||||
m.Sort(kit.MDB_PATH)
|
||||
case "name", "template":
|
||||
m.Cmdy(nfs.DIR, m.Conf(DREAM, kit.META_PATH), "path,size,time")
|
||||
m.SortStrR(kit.MDB_PATH)
|
||||
}
|
||||
}},
|
||||
gdb.START: {Name: "start type=worker,server repos name", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.START: {Name: "start type=worker,server repos name template", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(SPACE, m.Option(ROUTE), DREAM, gdb.START, arg)
|
||||
}},
|
||||
gdb.STOP: {Name: "stop", Help: "结束", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user