mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
add code.install
This commit is contained in:
parent
b851b0c31b
commit
345a8f28c6
@ -92,7 +92,7 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块",
|
|||||||
}}))
|
}}))
|
||||||
}},
|
}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Save(RUNTIME, SYSTEM)
|
m.Save(RUNTIME, SYSTEM, DAEMON)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
RUNTIME: {Name: "runtime name auto", Help: "运行环境", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
RUNTIME: {Name: "runtime name auto", Help: "运行环境", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
@ -33,11 +33,9 @@ func _daemon_show(m *ice.Message, cmd *exec.Cmd, out, err string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h := m.Rich(DAEMON, nil, kit.Dict(
|
h := m.Rich(DAEMON, nil, kit.Dict(
|
||||||
kit.MDB_TYPE, "shell", kit.MDB_NAME, cmd.Process.Pid, kit.MDB_TEXT, strings.Join(cmd.Args, " "),
|
kit.MDB_TYPE, "shell", kit.MDB_NAME, strings.Join(cmd.Args, " "),
|
||||||
kit.MDB_EXTRA, kit.Dict(
|
kit.MDB_DIR, cmd.Dir, kit.MDB_PID, cmd.Process.Pid, kit.MDB_STATUS, StatusStart,
|
||||||
kit.MDB_STATUS, StatusStart,
|
kit.MDB_EXTRA, kit.Dict(CMD_STDOUT, out, CMD_STDERR, err),
|
||||||
CMD_STDOUT, out, CMD_STDERR, err,
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
m.Log_EXPORT(kit.MDB_META, DAEMON, kit.MDB_KEY, h, kit.MDB_PID, cmd.Process.Pid)
|
m.Log_EXPORT(kit.MDB_META, DAEMON, kit.MDB_KEY, h, kit.MDB_PID, cmd.Process.Pid)
|
||||||
m.Echo("%d", cmd.Process.Pid)
|
m.Echo("%d", cmd.Process.Pid)
|
||||||
@ -46,13 +44,13 @@ func _daemon_show(m *ice.Message, cmd *exec.Cmd, out, err string) {
|
|||||||
if e := cmd.Wait(); e != nil {
|
if e := cmd.Wait(); e != nil {
|
||||||
m.Warn(e != nil, "%v wait: %s", cmd.Args, e)
|
m.Warn(e != nil, "%v wait: %s", cmd.Args, e)
|
||||||
m.Richs(DAEMON, nil, h, func(key string, value map[string]interface{}) {
|
m.Richs(DAEMON, nil, h, func(key string, value map[string]interface{}) {
|
||||||
kit.Value(value, kit.Keys(kit.MDB_EXTRA, kit.MDB_STATUS), StatusError)
|
kit.Value(value, kit.MDB_STATUS, StatusError)
|
||||||
kit.Value(value, kit.Keys(kit.MDB_EXTRA, kit.MDB_ERROR), e)
|
kit.Value(value, kit.Keys(kit.MDB_EXTRA, kit.MDB_ERROR), e)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
m.Cost("%v exit: %v", cmd.Args, cmd.ProcessState.ExitCode())
|
m.Cost("%v exit: %v", cmd.Args, cmd.ProcessState.ExitCode())
|
||||||
m.Richs(DAEMON, nil, h, func(key string, value map[string]interface{}) {
|
m.Richs(DAEMON, nil, h, func(key string, value map[string]interface{}) {
|
||||||
kit.Value(value, kit.Keys(kit.MDB_EXTRA, kit.MDB_STATUS), StatusClose)
|
kit.Value(value, kit.MDB_STATUS, StatusClose)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -66,7 +64,28 @@ func init() {
|
|||||||
DAEMON: {Name: "daemon", Help: "守护进程", Value: kit.Data()},
|
DAEMON: {Name: "daemon", Help: "守护进程", Value: kit.Data()},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
DAEMON: {Name: "daemon cmd arg...", Help: "守护进程", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
DAEMON: {Name: "daemon hash 查看:button=auto 清理:button", Help: "守护进程", Action: map[string]*ice.Action{
|
||||||
|
"delete": {Name: "delete", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy("mdb.delete", DAEMON, "", "hash", "hash", m.Option("hash"))
|
||||||
|
}},
|
||||||
|
|
||||||
|
"prune": {Name: "prune", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Richs(DAEMON, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
|
if strings.Count(m.Cmdx(SYSTEM, "ps", value["pid"]), "\n") > 1 {
|
||||||
|
value["status"] = "start"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Conf(DAEMON, kit.Keys("hash", key), "")
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Option("fields", "time,hash,status,pid,name,dir")
|
||||||
|
m.Cmdy("mdb.select", DAEMON, "", "hash")
|
||||||
|
m.Sort("time", "time_r")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
m.Option(CMD_TYPE, DAEMON)
|
m.Option(CMD_TYPE, DAEMON)
|
||||||
m.Cmdy(SYSTEM, arg)
|
m.Cmdy(SYSTEM, arg)
|
||||||
}},
|
}},
|
||||||
|
@ -104,14 +104,19 @@ func _cache_upload(m *ice.Message, r *http.Request) (kind, name, file, size stri
|
|||||||
func _cache_download(m *ice.Message, r *http.Response) (file, size string) {
|
func _cache_download(m *ice.Message, r *http.Response) (file, size string) {
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
progress, _ := m.Optionv("progress").(func(int, int))
|
||||||
|
|
||||||
total := kit.Int(kit.Select("1", r.Header.Get("Content-Length")))
|
total := kit.Int(kit.Select("1", r.Header.Get("Content-Length")))
|
||||||
if f, p, e := kit.Create(path.Join("var/tmp", kit.Hashs("uniq"))); m.Assert(e) {
|
if f, p, e := kit.Create(path.Join("var/tmp", kit.Hashs("uniq"))); m.Assert(e) {
|
||||||
size, buf := 0, make([]byte, 1024)
|
size, buf := 0, make([]byte, 1024)
|
||||||
for {
|
for {
|
||||||
if n, _ := r.Body.Read(buf); n > 0 {
|
if n, _ := r.Body.Read(buf); n > 0 {
|
||||||
f.Write(buf[0:n])
|
f.Write(buf[0:n])
|
||||||
size += n
|
if size += n; progress != nil {
|
||||||
m.Log_IMPORT(kit.MDB_FILE, p, "per", size*100/total, kit.MDB_SIZE, kit.FmtSize(int64(size)), "total", kit.FmtSize(int64(total)))
|
progress(size, total)
|
||||||
|
} else {
|
||||||
|
m.Log_IMPORT(kit.MDB_FILE, p, "per", size*100/total, kit.MDB_SIZE, kit.FmtSize(int64(size)), "total", kit.FmtSize(int64(total)))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
f.Close()
|
f.Close()
|
||||||
break
|
break
|
||||||
|
@ -179,7 +179,7 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
|||||||
r.URL.Path = strings.Replace(r.URL.Path, "/debug", "/code", -1)
|
r.URL.Path = strings.Replace(r.URL.Path, "/debug", "/code", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.URL.Path == "/" && m.Conf(SERVE, "meta.init") != "true" {
|
if r.URL.Path == "/" && m.Conf(SERVE, "meta.init") != "true" && len(ice.BinPack) == 0 {
|
||||||
if _, e := os.Stat(m.Conf(SERVE, "meta.volcanos.path")); e == nil {
|
if _, e := os.Stat(m.Conf(SERVE, "meta.volcanos.path")); e == nil {
|
||||||
// 初始化成功
|
// 初始化成功
|
||||||
m.Conf(SERVE, "meta.init", "true")
|
m.Conf(SERVE, "meta.init", "true")
|
||||||
|
@ -299,6 +299,10 @@ func init() {
|
|||||||
_share_repos(m, path.Join(strings.Split(cmd, "/")[2:5]...), arg[6:]...)
|
_share_repos(m, path.Join(strings.Split(cmd, "/")[2:5]...), arg[6:]...)
|
||||||
}},
|
}},
|
||||||
"/publish/": {Name: "/publish/", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/publish/": {Name: "/publish/", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if arg[0] == "order.js" && len(ice.BinPack) > 0 {
|
||||||
|
m.Render(ice.RENDER_RESULT, "{}")
|
||||||
|
return
|
||||||
|
}
|
||||||
if p := m.Option("pod"); p != "" {
|
if p := m.Option("pod"); p != "" {
|
||||||
m.Option("pod", "")
|
m.Option("pod", "")
|
||||||
_share_remote(m, p, arg...)
|
_share_remote(m, p, arg...)
|
||||||
|
@ -145,10 +145,14 @@ func init() {
|
|||||||
// 请求方法
|
// 请求方法
|
||||||
method := kit.Select("POST", client["method"])
|
method := kit.Select("POST", client["method"])
|
||||||
switch arg = arg[1:]; arg[0] {
|
switch arg = arg[1:]; arg[0] {
|
||||||
case "POST":
|
|
||||||
method, arg = "POST", arg[1:]
|
|
||||||
case "GET":
|
case "GET":
|
||||||
method, arg = "GET", arg[1:]
|
method, arg = "GET", arg[1:]
|
||||||
|
case "PUT":
|
||||||
|
method, arg = "PUT", arg[1:]
|
||||||
|
case "POST":
|
||||||
|
method, arg = "POST", arg[1:]
|
||||||
|
case "DELETE":
|
||||||
|
method, arg = "DELETE", arg[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求地址
|
// 请求地址
|
||||||
@ -240,9 +244,7 @@ func init() {
|
|||||||
if web.Client == nil {
|
if web.Client == nil {
|
||||||
web.Client = &http.Client{Timeout: kit.Duration(kit.Format(client["timeout"]))}
|
web.Client = &http.Client{Timeout: kit.Duration(kit.Format(client["timeout"]))}
|
||||||
}
|
}
|
||||||
if method == "POST" {
|
m.Info("%s: %s", req.Header.Get("Content-Length"), req.Header.Get("Content-Type"))
|
||||||
m.Info("%s: %s", req.Header.Get("Content-Length"), req.Header.Get("Content-Type"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
res, e := web.Client.Do(req)
|
res, e := web.Client.Do(req)
|
||||||
@ -251,8 +253,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查结果
|
// 检查结果
|
||||||
if m.Cost("%s %s: %s", res.Status, res.Header.Get("Content-Length"), res.Header.Get("Content-Type")); m.Warn(res.StatusCode != http.StatusOK, "%s", res.Status) {
|
m.Cost("%s %s: %s", res.Status, res.Header.Get("Content-Length"), res.Header.Get("Content-Type"))
|
||||||
return
|
if m.Warn(res.StatusCode != http.StatusOK, "%s", res.Status) {
|
||||||
|
m.Set(ice.MSG_RESULT)
|
||||||
|
// return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 缓存变量
|
// 缓存变量
|
||||||
|
@ -52,20 +52,20 @@ func init() {
|
|||||||
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy("web.code.webpack", "pack")
|
m.Cmdy("web.code.webpack", "pack")
|
||||||
|
|
||||||
if f, _, e := kit.Create("usr/volcanos/pack/" + m.Option("name") + ".js"); m.Assert(e) {
|
if f, _, e := kit.Create("usr/publish/webpack/" + m.Option("name") + ".js"); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
data := kit.UnMarshal(m.Option("content"))
|
|
||||||
f.WriteString(`Volcanos.meta.pack = ` + kit.Formats(data))
|
f.WriteString(`Volcanos.meta.pack = ` + kit.Formats(kit.UnMarshal(m.Option("content"))))
|
||||||
}
|
}
|
||||||
|
|
||||||
if f, p, e := kit.Create("usr/volcanos/pack/" + m.Option("name") + ".html"); m.Assert(e) {
|
if f, p, e := kit.Create("usr/publish/webpack/" + m.Option("name") + ".html"); m.Assert(e) {
|
||||||
f.WriteString(fmt.Sprintf(_pack,
|
f.WriteString(fmt.Sprintf(_pack,
|
||||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.css"),
|
m.Cmdx(nfs.CAT, "usr/volcanos/cache.css"),
|
||||||
m.Cmdx(nfs.CAT, "usr/volcanos/index.css"),
|
m.Cmdx(nfs.CAT, "usr/volcanos/index.css"),
|
||||||
|
|
||||||
m.Cmdx(nfs.CAT, "usr/volcanos/proto.js"),
|
m.Cmdx(nfs.CAT, "usr/volcanos/proto.js"),
|
||||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.js"),
|
m.Cmdx(nfs.CAT, "usr/volcanos/cache.js"),
|
||||||
m.Cmdx(nfs.CAT, "usr/volcanos/pack/"+m.Option("name")+".js"),
|
m.Cmdx(nfs.CAT, "usr/publish/webpack/"+m.Option("name")+".js"),
|
||||||
m.Cmdx(nfs.CAT, "usr/volcanos/index.js"),
|
m.Cmdx(nfs.CAT, "usr/volcanos/index.js"),
|
||||||
))
|
))
|
||||||
m.Echo(p)
|
m.Echo(p)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
@ -247,7 +248,7 @@ func init() {
|
|||||||
m.Cmdy("/storm", arg[1:])
|
m.Cmdy("/storm", arg[1:])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.Option("_source") == "" && m.Option(ice.MSG_SESSID) == "" {
|
if m.Option("_source") == "" && m.Option(ice.MSG_SESSID) == "" && !tcp.IPIsLocal(m, m.Option(ice.MSG_USERIP)) {
|
||||||
m.Render("status", "401")
|
m.Render("status", "401")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const ( // CODE
|
const ( // CODE
|
||||||
INSTALL = "_install"
|
// INSTALL = "_install"
|
||||||
PREPARE = "_prepare"
|
PREPARE = "_prepare"
|
||||||
PROJECT = "_project"
|
PROJECT = "_project"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Index = &ice.Context{Name: "code", Help: "编程中心",
|
var Index = &ice.Context{Name: "code", Help: "编程中心",
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
INSTALL: {Name: "install", Help: "安装", Value: kit.Data(
|
"_install": {Name: "install", Help: "安装", Value: kit.Data(
|
||||||
"path", "usr/install", "target", "usr/local",
|
"path", "usr/install", "target", "usr/local",
|
||||||
"linux", "https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz",
|
"linux", "https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz",
|
||||||
"darwin", "https://dl.google.com/go/go1.14.6.darwin-amd64.tar.gz",
|
"darwin", "https://dl.google.com/go/go1.14.6.darwin-amd64.tar.gz",
|
||||||
@ -52,21 +52,21 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
|
|||||||
m.Cmd(mdb.ENGINE, mdb.CREATE, BENCH)
|
m.Cmd(mdb.ENGINE, mdb.CREATE, BENCH)
|
||||||
}},
|
}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Save("login")
|
m.Save("login", INSTALL)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
INSTALL: {Name: "install url 安装:button", Help: "安装", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"_install": {Name: "install url 安装:button", Help: "安装", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
target := m.Conf(INSTALL, kit.Keys("meta", runtime.GOOS))
|
target := m.Conf("_install", kit.Keys("meta", runtime.GOOS))
|
||||||
|
|
||||||
p := path.Join(m.Conf(INSTALL, "meta.path"), path.Base(target))
|
p := path.Join(m.Conf("_install", "meta.path"), path.Base(target))
|
||||||
if _, e := os.Stat(p); e != nil {
|
if _, e := os.Stat(p); e != nil {
|
||||||
// 下载
|
// 下载
|
||||||
msg := m.Cmd(web.SPIDE, "dev", web.CACHE, http.MethodGet, target)
|
msg := m.Cmd(web.SPIDE, "dev", web.CACHE, http.MethodGet, target)
|
||||||
m.Cmd(web.CACHE, web.WATCH, msg.Append(web.DATA), p)
|
m.Cmd(web.CACHE, web.WATCH, msg.Append(web.DATA), p)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.MkdirAll(m.Conf(INSTALL, kit.Keys("meta.target")), ice.MOD_DIR)
|
os.MkdirAll(m.Conf("_install", kit.Keys("meta.target")), ice.MOD_DIR)
|
||||||
m.Cmdy(cli.SYSTEM, "tar", "xvf", p, "-C", m.Conf(INSTALL, kit.Keys("meta.target")))
|
m.Cmdy(cli.SYSTEM, "tar", "xvf", p, "-C", m.Conf("_install", kit.Keys("meta.target")))
|
||||||
}},
|
}},
|
||||||
PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
export := []string{}
|
export := []string{}
|
||||||
@ -78,7 +78,7 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
|
|||||||
export GOROOT=%s GOPATH=%s:$GOPATH GOBIN=%s
|
export GOROOT=%s GOPATH=%s:$GOPATH GOBIN=%s
|
||||||
export PATH=$GOBIN:$GOROOT/bin:$PATH
|
export PATH=$GOBIN:$GOROOT/bin:$PATH
|
||||||
export %s
|
export %s
|
||||||
`, kit.Path(m.Conf(INSTALL, kit.Keys("meta.target")), "go"), kit.Path("src"), kit.Path("bin"), strings.Join(export, " ")))
|
`, kit.Path(m.Conf("_install", kit.Keys("meta.target")), "go"), kit.Path("src"), kit.Path("bin"), strings.Join(export, " ")))
|
||||||
}},
|
}},
|
||||||
PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
}},
|
}},
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"os"
|
"os"
|
||||||
@ -39,7 +38,15 @@ func init() {
|
|||||||
main := kit.Select("src/main.go", arg, 2)
|
main := kit.Select("src/main.go", arg, 2)
|
||||||
arch := kit.Select(m.Conf(cli.RUNTIME, "host.GOARCH"), arg, 1)
|
arch := kit.Select(m.Conf(cli.RUNTIME, "host.GOARCH"), arg, 1)
|
||||||
goos := kit.Select(m.Conf(cli.RUNTIME, "host.GOOS"), arg, 0)
|
goos := kit.Select(m.Conf(cli.RUNTIME, "host.GOOS"), arg, 0)
|
||||||
file := path.Join(m.Conf(cmd, "meta.path"), kit.Keys("ice", goos, arch))
|
file := ""
|
||||||
|
if m.Option(cli.CMD_DIR) == "" {
|
||||||
|
file = path.Join(m.Conf(cmd, "meta.path"), kit.Keys(kit.Select("ice", m.Option("name")), goos, arch))
|
||||||
|
} else {
|
||||||
|
file = kit.Keys(kit.Select("ice", m.Option("name")), goos, arch)
|
||||||
|
}
|
||||||
|
if goos == "windows" {
|
||||||
|
file += ".exe"
|
||||||
|
}
|
||||||
|
|
||||||
// 编译参数
|
// 编译参数
|
||||||
m.Optionv(cli.CMD_ENV, kit.Simple(m.Confv(COMPILE, "meta.env"), "GOARCH", arch, "GOOS", goos))
|
m.Optionv(cli.CMD_ENV, kit.Simple(m.Confv(COMPILE, "meta.env"), "GOARCH", arch, "GOOS", goos))
|
||||||
@ -49,7 +56,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 编译记录
|
// 编译记录
|
||||||
m.Cmdy(web.STORY, web.CATCH, "bin", file)
|
// m.Cmdy(web.STORY, web.CATCH, "bin", file)
|
||||||
m.Log_EXPORT("source", main, "target", file)
|
m.Log_EXPORT("source", main, "target", file)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
60
core/code/install.go
Normal file
60
core/code/install.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package code
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
|
"github.com/shylinux/icebergs/base/web"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
const INSTALL = "install"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.Merge(&ice.Context{
|
||||||
|
Configs: map[string]*ice.Config{
|
||||||
|
INSTALL: {Name: "install", Help: "安装", Value: kit.Data(
|
||||||
|
kit.MDB_SHORT, kit.MDB_NAME, "path", "usr/install",
|
||||||
|
)},
|
||||||
|
},
|
||||||
|
Commands: map[string]*ice.Command{
|
||||||
|
INSTALL: {Name: "install name=auto auto", Help: "安装", Action: map[string]*ice.Action{
|
||||||
|
"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{}) {
|
||||||
|
m.Push(key, value, []string{"time", "progress", "size", "name", "link"})
|
||||||
|
}) != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Cmd(mdb.INSERT, m.Prefix(INSTALL), "", mdb.HASH, kit.MDB_NAME, name, kit.MDB_LINK, arg[0])
|
||||||
|
m.Richs(INSTALL, "", name, func(key string, value map[string]interface{}) {
|
||||||
|
m.Optionv("progress", func(size int, total int) {
|
||||||
|
value["progress"], value["size"], value["total"] = size*100/total, size, total
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
msg := m.Cmd(web.SPIDE, "dev", "cache", http.MethodGet, arg[0])
|
||||||
|
p := path.Join(m.Conf(INSTALL, "meta.path"), name)
|
||||||
|
m.Cmdy(nfs.LINK, p, msg.Append("file"))
|
||||||
|
|
||||||
|
m.Option(cli.CMD_DIR, m.Conf(INSTALL, "meta.path"))
|
||||||
|
m.Cmd(cli.SYSTEM, "tar", "xvf", name)
|
||||||
|
m.Echo(p)
|
||||||
|
}},
|
||||||
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option("fields", "time,progress,size,total,name,link")
|
||||||
|
if len(arg) > 0 {
|
||||||
|
m.Cmdy(mdb.SELECT, m.Prefix(INSTALL), "", mdb.HASH, kit.MDB_NAME, arg[0])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Cmdy(mdb.SELECT, m.Prefix(INSTALL), "", mdb.HASH)
|
||||||
|
m.Sort(kit.MDB_TIME, "time_r")
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}, nil)
|
||||||
|
}
|
@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
@ -116,6 +117,26 @@ func _pack_intshell(m *ice.Message, pack *os.File) {
|
|||||||
pack.WriteString(fmt.Sprintf(` "%s": []byte{%v},`+"\n", "usr/intshell/"+value["path"], what[1:len(what)-1]))
|
pack.WriteString(fmt.Sprintf(` "%s": []byte{%v},`+"\n", "usr/intshell/"+value["path"], what[1:len(what)-1]))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func _pack_contexts(m *ice.Message, pack *os.File) {
|
||||||
|
m.Option(nfs.DIR_ROOT, "src")
|
||||||
|
m.Option(nfs.DIR_DEEP, "true")
|
||||||
|
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
||||||
|
|
||||||
|
what := ""
|
||||||
|
for _, file := range []string{"src/main.go", "src/main.shy", "src/main.svg"} {
|
||||||
|
if f, e := os.Open(file); e == nil {
|
||||||
|
defer f.Close()
|
||||||
|
if b, e := ioutil.ReadAll(f); e == nil {
|
||||||
|
what = fmt.Sprintf("%v", b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(what) > 0 {
|
||||||
|
what = strings.ReplaceAll(what, " ", ",")
|
||||||
|
pack.WriteString(fmt.Sprintf(` "%s": []byte{%v},`+"\n", file, what[1:len(what)-1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pack.WriteString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
WEBPACK = "webpack"
|
WEBPACK = "webpack"
|
||||||
@ -129,13 +150,12 @@ func init() {
|
|||||||
WEBPACK: {Name: "webpack", Help: "打包", Action: map[string]*ice.Action{
|
WEBPACK: {Name: "webpack", Help: "打包", Action: map[string]*ice.Action{
|
||||||
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(nfs.DIR_ROOT, "usr/volcanos")
|
m.Option(nfs.DIR_ROOT, "usr/volcanos")
|
||||||
m.Option(nfs.DIR_DEEP, "true")
|
|
||||||
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
||||||
|
m.Option(nfs.DIR_DEEP, "true")
|
||||||
|
|
||||||
js, p, e := kit.Create("usr/volcanos/cache.js")
|
js, _, e := kit.Create("usr/volcanos/cache.js")
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
defer js.Close()
|
defer js.Close()
|
||||||
m.Echo(p)
|
|
||||||
|
|
||||||
css, _, e := kit.Create("usr/volcanos/cache.css")
|
css, _, e := kit.Create("usr/volcanos/cache.css")
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
@ -153,47 +173,56 @@ func init() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range []string{"frame.js"} {
|
for _, k := range []string{"frame.js"} {
|
||||||
js.WriteString(`_can_name = "` + path.Join("/", k) + "\"\n")
|
js.WriteString(`_can_name = "` + path.Join("/", k) + "\"\n")
|
||||||
js.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+k))
|
js.WriteString(m.Cmdx(nfs.CAT, "usr/volcanos/"+k))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(nfs.DIR_ROOT, "usr/volcanos")
|
m.Option(nfs.DIR_ROOT, "usr/publish")
|
||||||
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
||||||
m.Option(nfs.DIR_DEEP, "true")
|
m.Option(nfs.DIR_DEEP, "true")
|
||||||
m.Cmdy(nfs.DIR, "pack")
|
|
||||||
m.Table(func(index int, value map[string]string, head []string) {
|
m.Cmdy(nfs.DIR, "webpack").Table(func(index int, value map[string]string, head []string) {
|
||||||
m.Push("link", m.Cmdx(mdb.RENDER, web.RENDER.Download, "/"+value["path"]))
|
m.Push("link", m.Cmdx(mdb.RENDER, web.RENDER.Download, "/publish/"+value["path"]))
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
BINPACK: {Name: "binpack", Help: "打包", Action: map[string]*ice.Action{
|
BINPACK: {Name: "binpack path 查看:button 返回:button 打包:button", Help: "打包", Action: map[string]*ice.Action{
|
||||||
"pack": {Name: "pack", Help: "pack", Hand: func(m *ice.Message, arg ...string) {
|
"pack": {Name: "pack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||||
pack, p, e := kit.Create("usr/icebergs/pack/binpack.go")
|
m.Option("name", "demo")
|
||||||
m.Assert(e)
|
if pack, p, e := kit.Create("usr/publish/binpack/" + m.Option("name") + ".go"); m.Assert(e) {
|
||||||
defer pack.Close()
|
defer pack.Close()
|
||||||
|
|
||||||
pack.WriteString(`package pack` + "\n\n")
|
pack.WriteString(m.Cmdx(nfs.CAT, "src/main.go"))
|
||||||
pack.WriteString(`import "github.com/shylinux/icebergs"` + "\n\n")
|
|
||||||
pack.WriteString(`func init() {` + "\n")
|
|
||||||
pack.WriteString(` ice.BinPack = map[string][]byte{` + "\n")
|
|
||||||
|
|
||||||
_pack_volcanos(m, pack)
|
pack.WriteString("\n")
|
||||||
_pack_learning(m, pack)
|
pack.WriteString(`func init() {` + "\n")
|
||||||
_pack_icebergs(m, pack)
|
pack.WriteString(` ice.BinPack = map[string][]byte{` + "\n")
|
||||||
_pack_intshell(m, pack)
|
|
||||||
|
|
||||||
pack.WriteString(` }` + "\n")
|
_pack_volcanos(m, pack)
|
||||||
pack.WriteString(`}` + "\n")
|
_pack_learning(m, pack)
|
||||||
m.Echo(p)
|
_pack_icebergs(m, pack)
|
||||||
|
_pack_intshell(m, pack)
|
||||||
|
_pack_contexts(m, pack)
|
||||||
|
|
||||||
|
pack.WriteString(` }` + "\n")
|
||||||
|
pack.WriteString(`}` + "\n")
|
||||||
|
m.Echo(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Option(cli.CMD_DIR, "usr/publish/binpack")
|
||||||
|
m.Cmd("compile", "linux", "amd64", m.Option("name")+".go")
|
||||||
|
m.Cmd("compile", "darwin", "amd64", m.Option("name")+".go")
|
||||||
|
m.Cmd("compile", "windows", "amd64", m.Option("name")+".go")
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(nfs.DIR_ROOT, "usr/icebergs")
|
m.Option(nfs.DIR_ROOT, "usr/publish")
|
||||||
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
m.Option(nfs.DIR_TYPE, nfs.FILE)
|
||||||
m.Option(nfs.DIR_DEEP, "true")
|
m.Option(nfs.DIR_DEEP, "true")
|
||||||
m.Cmdy(nfs.DIR, "pack")
|
|
||||||
m.Table(func(index int, value map[string]string, head []string) {
|
m.Cmdy(nfs.DIR, "binpack").Table(func(index int, value map[string]string, head []string) {
|
||||||
m.Push("link", m.Cmdx(mdb.RENDER, web.RENDER.Download, value["path"], "/share/local/usr/icebergs/"+value["path"]))
|
m.Push("link", m.Cmdx(mdb.RENDER, web.RENDER.Download, "/publish/"+value["path"]))
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
MODPACK: {Name: "modpack path=auto 查看:button 返回:button 创建:button", Help: "打包", Meta: kit.Dict(
|
MODPACK: {Name: "modpack path=auto 查看:button 返回:button 创建:button", Help: "打包", Meta: kit.Dict(
|
||||||
|
3
init.go
3
init.go
@ -156,7 +156,8 @@ func Run(arg ...string) string {
|
|||||||
arg = os.Args[1:]
|
arg = os.Args[1:]
|
||||||
}
|
}
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
arg = append(arg, "web.space", "connect", "self")
|
// arg = append(arg, "web.space", "connect", "self")
|
||||||
|
arg = append(arg, "web.serve", "dev")
|
||||||
}
|
}
|
||||||
|
|
||||||
frame := &Frame{}
|
frame := &Frame{}
|
||||||
|
3
logs.go
3
logs.go
@ -43,6 +43,9 @@ func (m *Message) log(level string, str string, arg ...interface{}) *Message {
|
|||||||
default:
|
default:
|
||||||
suffix += " " + kit.FileLine(3, 2)
|
suffix += " " + kit.FileLine(3, 2)
|
||||||
}
|
}
|
||||||
|
if len(BinPack) > 0 {
|
||||||
|
prefix, suffix = "", ""
|
||||||
|
}
|
||||||
|
|
||||||
// 输出日志
|
// 输出日志
|
||||||
log.Info(fmt.Sprintf("%02d %9s %s%s %s%s", m.code, fmt.Sprintf("%4s->%-4s", m.source.Name, m.target.Name),
|
log.Info(fmt.Sprintf("%02d %9s %s%s %s%s", m.code, fmt.Sprintf("%4s->%-4s", m.source.Name, m.target.Name),
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package es
|
package es
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"path"
|
|
||||||
"runtime"
|
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
|
"github.com/shylinux/icebergs/core/code"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"os"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"path"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"runtime"
|
||||||
"github.com/shylinux/icebergs/core/code"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ES = "es"
|
const ES = "es"
|
||||||
@ -28,15 +28,74 @@ var Index = &ice.Context{Name: ES, Help: "搜索",
|
|||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||||
|
|
||||||
ES: {Name: "es 安装:button", Help: "搜索", Action: map[string]*ice.Action{
|
ES: {Name: "es hash=auto auto 启动:button 安装:button", Help: "搜索", Action: map[string]*ice.Action{
|
||||||
"install": {Name: "install", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
"install": {Name: "install", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
||||||
name := path.Base(m.Conf(ES, kit.Keys("meta", runtime.GOOS)))
|
m.Cmdy("web.code.install", "download", m.Conf(ES, kit.Keys(kit.MDB_META, runtime.GOOS)))
|
||||||
msg := m.Cmd(web.SPIDE, "dev", "cache", http.MethodGet, m.Conf(ES, kit.Keys("meta", runtime.GOOS)))
|
}},
|
||||||
m.Cmdy(nfs.LINK, path.Join("usr/install/", name), msg.Append("file"))
|
|
||||||
m.Option(cli.CMD_DIR, "usr/install")
|
"start": {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(cli.SYSTEM, "tar", "xvf", name)
|
name := path.Base(m.Conf(ES, kit.Keys(kit.MDB_META, runtime.GOOS)))
|
||||||
|
name = strings.Join(strings.Split(name, "-")[:2], "-")
|
||||||
|
|
||||||
|
port := m.Cmdx(tcp.PORT, "get")
|
||||||
|
p := "var/daemon/" + port
|
||||||
|
os.MkdirAll(p, ice.MOD_DIR)
|
||||||
|
for _, dir := range []string{"bin", "jdk", "lib", "logs", "config", "modules", "plugins"} {
|
||||||
|
m.Cmd(cli.SYSTEM, "cp", "-r", "usr/install/"+name+"/"+dir, p)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Option(cli.CMD_DIR, p)
|
||||||
|
m.Cmdy(cli.DAEMON, "bin/elasticsearch")
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Cmdy(cli.DAEMON)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(arg) == 1 {
|
||||||
|
m.Richs(cli.DAEMON, "", arg[0], func(key string, value map[string]interface{}) {
|
||||||
|
m.Cmdy("web.spide", "dev", "raw", "GET", "http://localhost:9200")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(arg) == 2 {
|
||||||
|
m.Richs(cli.DAEMON, "", arg[0], func(key string, value map[string]interface{}) {
|
||||||
|
m.Cmdy("web.spide", "dev", "raw", "GET", "http://localhost:9200")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
|
||||||
|
"index": {Name: "table index 创建:button", Help: "索引", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Cmdy(cli.DAEMON)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Option("header", "Content-Type", "application/json")
|
||||||
|
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", "PUT", "http://localhost:9200/"+arg[0]))))
|
||||||
|
}},
|
||||||
|
|
||||||
|
"mapping": {Name: "mapping index mapping 创建:button text:textarea", Help: "映射", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Cmdy(cli.DAEMON)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Option("header", "Content-Type", "application/json")
|
||||||
|
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", "PUT", "http://localhost:9200/"+arg[0]+"/_mapping/"+arg[1], "data", arg[2]))))
|
||||||
|
}},
|
||||||
|
|
||||||
|
"document": {Name: "table index=index_test mapping=mapping_test id=1 查看:button 添加:button data:textarea", Help: "文档", Action: map[string]*ice.Action{
|
||||||
|
mdb.INSERT: {Name: "insert", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) > 3 {
|
||||||
|
m.Option("header", "Content-Type", "application/json")
|
||||||
|
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", "PUT", "http://localhost:9200/"+arg[0]+"/"+arg[1]+"/"+arg[2], "data", arg[3]))))
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option("header", "Content-Type", "application/json")
|
||||||
|
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx("web.spide", "dev", "raw", "GET", "http://localhost:9200/"+arg[0]+"/"+arg[1]+"/"+arg[2]))))
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ refer `
|
|||||||
源码 https://github.com/elastic/elasticsearch
|
源码 https://github.com/elastic/elasticsearch
|
||||||
文档 https://www.elastic.co/guide/index.html
|
文档 https://www.elastic.co/guide/index.html
|
||||||
安装 https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
|
安装 https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
|
||||||
简介 https://www.jianshu.com/p/403c9d5b1463
|
|
||||||
入门 https://www.cnblogs.com/sunsky303/p/9438737.html
|
入门 https://www.cnblogs.com/sunsky303/p/9438737.html
|
||||||
`
|
`
|
||||||
|
|
||||||
section 下载
|
section 下载
|
||||||
refer `
|
refer `
|
||||||
windows https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-windows-x86_64.zip
|
windows https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-windows-x86_64.zip
|
||||||
@ -21,8 +21,12 @@ $ cd elasticsearch-7.3.2
|
|||||||
$ ./bin/elasticsearch
|
$ ./bin/elasticsearch
|
||||||
`
|
`
|
||||||
|
|
||||||
section 创建索引
|
section 体验
|
||||||
spark shell `
|
spark shell `
|
||||||
$ curl http://localhost:9200
|
$ curl http://localhost:9200
|
||||||
$ curl -XPUT "localhost:9200/index_test"
|
|
||||||
`
|
`
|
||||||
|
|
||||||
|
field document web.code.es.document
|
||||||
|
field es web.code.es.es
|
||||||
|
field install web.code.install
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
|||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
|
|
||||||
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"_install": {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
||||||
m.Cmd(cli.SYSTEM, "git", "clone", m.Conf("git", "meta.source"))
|
m.Cmd(cli.SYSTEM, "git", "clone", m.Conf("git", "meta.source"))
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ var Index = &ice.Context{Name: "tmux", Help: "工作台",
|
|||||||
})
|
})
|
||||||
}}))
|
}}))
|
||||||
}},
|
}},
|
||||||
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"_install": {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
||||||
m.Cmd(cli.SYSTEM, "git", "clone", "https://github.com/tmux/tmux")
|
m.Cmd(cli.SYSTEM, "git", "clone", "https://github.com/tmux/tmux")
|
||||||
}},
|
}},
|
||||||
|
@ -44,31 +44,34 @@ func _totp_get(key string, num int, per int64) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TOTP = "totp"
|
const TOTP = "totp"
|
||||||
|
const (
|
||||||
|
NEW = "new"
|
||||||
|
GET = "get"
|
||||||
|
)
|
||||||
|
|
||||||
var Index = &ice.Context{Name: "totp", Help: "动态码",
|
var Index = &ice.Context{Name: TOTP, Help: "动态码",
|
||||||
Caches: map[string]*ice.Cache{},
|
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
TOTP: {Name: "totp", Help: "动态码", Value: kit.Data(
|
TOTP: {Name: TOTP, Help: "动态码", Value: kit.Data(
|
||||||
kit.MDB_SHORT, "name", "share", "otpauth://totp/%s?secret=%s",
|
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_LINK, "otpauth://totp/%s?secret=%s",
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||||
|
|
||||||
"new": {Name: "new user [secret]", Help: "创建密钥", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
NEW: {Name: "new user [secret]", Help: "创建密钥", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
// 密钥列表
|
// 密钥列表
|
||||||
m.Richs("totp", nil, "*", func(key string, value map[string]interface{}) {
|
m.Richs(TOTP, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
m.Push(key, value, []string{"time", "name"})
|
m.Push(key, value, []string{kit.MDB_TIME, kit.MDB_NAME})
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Richs("totp", nil, arg[0], func(key string, value map[string]interface{}) {
|
if m.Richs(TOTP, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||||
// 密钥详情
|
// 密钥详情
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
m.Render(ice.RENDER_QRCODE, kit.Format(m.Conf("totp", "meta.share"), value["name"], value["text"]))
|
m.Render(ice.RENDER_QRCODE, kit.Format(m.Conf(TOTP, "meta.link"), value[kit.MDB_NAME], value[kit.MDB_TEXT]))
|
||||||
} else {
|
} else {
|
||||||
m.Push("detail", value)
|
m.Push("detail", value)
|
||||||
}
|
}
|
||||||
@ -82,14 +85,16 @@ var Index = &ice.Context{Name: "totp", Help: "动态码",
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加密钥
|
// 添加密钥
|
||||||
m.Log(ice.LOG_CREATE, "%s: %s", arg[0], m.Rich("totp", nil, kit.Dict(
|
m.Log(ice.LOG_CREATE, "%s: %s", arg[0], m.Rich(TOTP, nil, kit.Dict(
|
||||||
kit.MDB_NAME, arg[0], kit.MDB_TEXT, arg[1], kit.MDB_EXTRA, kit.Dict(arg[2:]),
|
kit.MDB_NAME, arg[0], kit.MDB_TEXT, arg[1], kit.MDB_EXTRA, kit.Dict(arg[2:]),
|
||||||
)))
|
)))
|
||||||
}},
|
}},
|
||||||
"get": {Name: "get [name [number [period]]] auto", Help: "获取密码", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
GET: {Name: "get [name [number [period]]] auto", Help: "获取密码", Meta: kit.Dict(
|
||||||
|
"_refresh", "1000",
|
||||||
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
// 密码列表
|
// 密码列表
|
||||||
m.Richs("totp", nil, "*", func(key string, value map[string]interface{}) {
|
m.Richs(TOTP, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
per := kit.Int64(kit.Select("30", value["period"]))
|
per := kit.Int64(kit.Select("30", value["period"]))
|
||||||
m.Push("time", m.Time())
|
m.Push("time", m.Time())
|
||||||
m.Push("rest", per-time.Now().Unix()%per)
|
m.Push("rest", per-time.Now().Unix()%per)
|
||||||
@ -97,12 +102,13 @@ var Index = &ice.Context{Name: "totp", Help: "动态码",
|
|||||||
m.Push("code", _totp_get(kit.Format(value["text"]), kit.Int(kit.Select("6", value["number"])), per))
|
m.Push("code", _totp_get(kit.Format(value["text"]), kit.Int(kit.Select("6", value["number"])), per))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
m.Sort(kit.MDB_NAME)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Richs("totp", nil, arg[0], func(key string, value map[string]interface{}) {
|
m.Richs(TOTP, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||||
// 获取密码
|
// 获取密码
|
||||||
m.Echo(_totp_get(kit.Format(value["text"]), kit.Int(kit.Select("6", arg, 1)), kit.Int64(kit.Select("30", arg, 2))))
|
m.Echo(_totp_get(kit.Format(value[kit.MDB_TEXT]), kit.Int(kit.Select("6", arg, 1)), kit.Int64(kit.Select("30", arg, 2))))
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -118,7 +118,7 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
|||||||
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"_install": {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
p := path.Join(m.Conf("install", "meta.path"), m.Conf("vim", "meta.version"))
|
p := path.Join(m.Conf("install", "meta.path"), m.Conf("vim", "meta.version"))
|
||||||
if _, e := os.Stat(p); e != nil {
|
if _, e := os.Stat(p); e != nil {
|
||||||
// 下载源码
|
// 下载源码
|
||||||
|
Loading…
x
Reference in New Issue
Block a user