mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt publish
This commit is contained in:
parent
6fcb5e1e79
commit
f1f89f67b8
@ -368,10 +368,11 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块",
|
||||
nil, []string{"time", "size", "type", "path"})
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
rg, _ := regexp.Compile(m.Option(DIR_REG))
|
||||
reg, _ := regexp.Compile(m.Option(DIR_REG))
|
||||
_file_list(m, kit.Select("./", m.Option(DIR_ROOT)), kit.Select("", arg, 0),
|
||||
0, m.Options(DIR_DEEP), kit.Select("both", m.Option(DIR_TYPE)), rg,
|
||||
0, m.Options(DIR_DEEP), kit.Select("both", m.Option(DIR_TYPE)), reg,
|
||||
strings.Split(kit.Select("time size path", strings.Join(arg[1:], " ")), " "))
|
||||
m.Sort(kit.MDB_TIME, "time_r")
|
||||
}},
|
||||
CAT: {Name: "cat file", Help: "查看", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_file_show(m, arg[0])
|
||||
|
@ -171,6 +171,10 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
|
||||
}
|
||||
}
|
||||
|
||||
if m.Option(ice.MSG_USERURL) == "/header" {
|
||||
// 免检
|
||||
return
|
||||
}
|
||||
if m.Warn(!m.Right(m.Option(ice.MSG_USERURL), m.Optionv(ice.MSG_CMDS))) {
|
||||
return
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
|
||||
m.Cmd(mdb.ENGINE, mdb.CREATE, BENCH)
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save("login", INSTALL)
|
||||
m.Save("login")
|
||||
}},
|
||||
|
||||
"_install": {Name: "install url 安装:button", Help: "安装", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -21,10 +22,95 @@ func init() {
|
||||
Configs: map[string]*ice.Config{
|
||||
INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_PATH, "usr/install",
|
||||
"contexts", kit.Dict(
|
||||
"tmux", kit.Dict(
|
||||
"centos", `
|
||||
yum update -y && yum install -y wget tmux curl
|
||||
wget {{.Option "host"}}/publish/tmux.conf
|
||||
tmux -f tmux.conf
|
||||
`,
|
||||
"ubuntu", `
|
||||
apt update -y && apt install -y wget tmux curl
|
||||
wget {{.Option "host"}}/publish/tmux.conf
|
||||
tmux -f tmux.conf
|
||||
`,
|
||||
"alpine", `
|
||||
apk update && apk add wget tmux curl
|
||||
wget {{.Option "host"}}/publish/tmux.conf
|
||||
tmux -f tmux.conf
|
||||
`,
|
||||
"darwin", `
|
||||
brew update && brew install wget tmux curl
|
||||
wget {{.Option "host"}}/publish/tmux.conf
|
||||
tmux -f tmux.conf
|
||||
`,
|
||||
),
|
||||
"base", kit.Dict(
|
||||
"centos", `
|
||||
yum update -y && yum install -y curl
|
||||
mkdir contexts; cd contexts
|
||||
ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh
|
||||
`,
|
||||
"ubuntu", `
|
||||
apt update -y && apt install -y curl
|
||||
mkdir contexts; cd contexts
|
||||
ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh
|
||||
`,
|
||||
"alpine", `
|
||||
apk update && apk add curl
|
||||
mkdir contexts; cd contexts
|
||||
ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh
|
||||
`,
|
||||
"darwin", `
|
||||
brew update && brew install curl
|
||||
mkdir contexts; cd contexts
|
||||
ctx_dev={{.Option "host"}}; curl $ctx_dev/publish/ice.sh | sh
|
||||
`,
|
||||
),
|
||||
"miss", kit.Dict(
|
||||
"centos", `
|
||||
yum update -y && yum install -y git vim make go
|
||||
git clone https://github.com/shylinux/contexts && cd contexts
|
||||
source etc/miss.sh
|
||||
`,
|
||||
"ubuntu", `
|
||||
apt update -y && apt install -y git vim make golang
|
||||
git clone https://github.com/shylinux/contexts && cd contexts
|
||||
source etc/miss.sh
|
||||
`,
|
||||
"alpine", `
|
||||
apk update && apk add git vim make go
|
||||
git clone https://github.com/shylinux/contexts && cd contexts
|
||||
source etc/miss.sh
|
||||
`,
|
||||
"darwin", `
|
||||
brew update && brew install git vim make
|
||||
git clone https://github.com/shylinux/contexts && cd contexts
|
||||
source etc/miss.sh
|
||||
`,
|
||||
),
|
||||
),
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
INSTALL: {Name: "install name=auto port=auto path=auto auto", Help: "安装", Meta: kit.Dict(), Action: map[string]*ice.Action{
|
||||
"contexts": {Name: "contexts item os", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
||||
m.Option("host", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(u.Host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(u.Host, ":"), 1)))
|
||||
|
||||
txt, sys := "hello world", kit.Select("centos", arg, 1)
|
||||
switch text := m.Confv(INSTALL, kit.Keys("meta.contexts", kit.Select("tmux", arg, 0))).(type) {
|
||||
case map[string]interface{}:
|
||||
m.Cmdy("web.wiki.spark", sys)
|
||||
txt = kit.Format(text[sys])
|
||||
case string:
|
||||
txt = text
|
||||
}
|
||||
|
||||
if buf, err := kit.Render(txt, m); m.Assert(err) {
|
||||
m.Cmdy("web.wiki.spark", "shell", string(buf))
|
||||
}
|
||||
}},
|
||||
"download": {Name: "download link", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
name := path.Base(arg[0])
|
||||
if m.Richs(INSTALL, "", name, func(key string, value map[string]interface{}) {
|
||||
|
@ -4,43 +4,61 @@ import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
const PUBLISH = "publish"
|
||||
|
||||
func _publish_file(m *ice.Message, file string, arg ...string) string {
|
||||
if s, e := os.Stat(file); m.Assert(e) && s.IsDir() {
|
||||
// 打包目录
|
||||
p := path.Base(file) + ".tar.gz"
|
||||
m.Cmd(cli.SYSTEM, "tar", "-zcf", p, file)
|
||||
defer func() { os.Remove(p) }()
|
||||
file = p
|
||||
}
|
||||
|
||||
// 发布文件
|
||||
target := path.Join(m.Conf(PUBLISH, kit.META_PATH), kit.Select(path.Base(file), arg, 0))
|
||||
m.Cmd(nfs.LINK, target, file)
|
||||
|
||||
// 发布记录
|
||||
// m.Cmdy(web.STORY, web.CATCH, "bin", target)
|
||||
m.Log_EXPORT(PUBLISH, target, "from", file)
|
||||
return target
|
||||
}
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
PUBLISH: {Name: "publish", Help: "发布", Value: kit.Data("path", "usr/publish")},
|
||||
PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_PATH, "usr/publish",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
PUBLISH: {Name: "publish [source]", Help: "发布", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
// 目录列表
|
||||
m.Cmdy(nfs.DIR, m.Conf(cmd, "meta.path"), "time size path")
|
||||
return
|
||||
}
|
||||
|
||||
if s, e := os.Stat(arg[0]); m.Assert(e) && s.IsDir() {
|
||||
// 打包目录
|
||||
p := path.Base(arg[0]) + ".tar.gz"
|
||||
m.Cmd(cli.SYSTEM, "tar", "-zcf", p, arg[0])
|
||||
defer func() { os.Remove(p) }()
|
||||
arg[0] = p
|
||||
}
|
||||
|
||||
// 发布文件
|
||||
target := path.Join(m.Conf(cmd, "meta.path"), path.Base(arg[0]))
|
||||
m.Cmd(nfs.LINK, target, arg[0])
|
||||
|
||||
// 发布记录
|
||||
m.Cmdy(web.STORY, web.CATCH, "bin", target)
|
||||
m.Log_EXPORT("source", arg[0], "target", target)
|
||||
PUBLISH: {Name: "publish path=auto auto 火山架 冰山架 神农架", Help: "发布", Action: map[string]*ice.Action{
|
||||
"ish": {Name: "ish", Help: "神农架", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_REG, ".*\\.(sh|vim|conf)")
|
||||
m.Cmdy(nfs.DIR, m.Conf(PUBLISH, kit.META_PATH), "time size line path link")
|
||||
}},
|
||||
"ice": {Name: "ice", Help: "冰山架", Hand: func(m *ice.Message, arg ...string) {
|
||||
_publish_file(m, "bin/ice.bin", fmt.Sprintf("ice.%s.%s", runtime.GOOS, runtime.GOARCH))
|
||||
_publish_file(m, "bin/ice.sh")
|
||||
m.Option(nfs.DIR_REG, "ice.*")
|
||||
m.Cmdy(nfs.DIR, m.Conf(PUBLISH, kit.META_PATH), "time size path link")
|
||||
}},
|
||||
"can": {Name: "can", Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_REG, ".*\\.(js|css|html)")
|
||||
m.Cmdy(nfs.DIR, m.Conf(PUBLISH, kit.META_PATH), "time size line path link")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, m.Conf(cmd, kit.META_PATH))
|
||||
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), "time size path")
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user