mirror of
https://shylinux.com/x/icebergs
synced 2025-05-05 20:57:02 +08:00
opt some
This commit is contained in:
parent
ed0f24425d
commit
50279c8fc4
@ -138,21 +138,25 @@ func init() {
|
|||||||
},
|
},
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
DREAM: {Name: DREAM, Help: "梦想家", Value: kit.Data(kit.MDB_PATH, "usr/local/work",
|
DREAM: {Name: DREAM, Help: "梦想家", Value: kit.Data(kit.MDB_PATH, "usr/local/work",
|
||||||
"cmd", []interface{}{"ice.bin", SPACE, tcp.DIAL},
|
kit.SSH_CMD, []interface{}{"ice.bin", SPACE, tcp.DIAL},
|
||||||
"env", kit.Dict("ctx_log", "bin/boot.log"),
|
kit.SSH_ENV, kit.Dict(ice.CTX_LOG, ice.BIN_BOOTLOG),
|
||||||
"miss", `#!/bin/bash
|
"miss", `#!/bin/bash
|
||||||
[ -f ~/.ish/plug.sh ] || [ -f $PWD/.ish/plug.sh ] || git clone ${ISH_CONF_HUB_PROXY:="https://"}github.com/shylinux/intshell $PWD/.ish
|
[ -f $PWD/.ish/plug.sh ] || [ -f $HOME/.ish/plug.sh ] || git clone ${ISH_CONF_HUB_PROXY:="https://"}github.com/shylinux/intshell $PWD/.ish
|
||||||
[ "$ISH_CONF_PRE" != "" ] || source $PWD/.ish/plug.sh || source ~/.ish/plug.sh
|
[ "$ISH_CONF_PRE" != "" ] || source $PWD/.ish/plug.sh || source $HOME/.ish/plug.sh
|
||||||
require miss.sh
|
require miss.sh
|
||||||
|
|
||||||
|
# ish_miss_prepare_compile
|
||||||
ish_miss_prepare_develop
|
ish_miss_prepare_develop
|
||||||
ish_miss_prepare_compile
|
|
||||||
ish_miss_prepare_install
|
ish_miss_prepare_install
|
||||||
|
|
||||||
# ish_miss_prepare_volcanos
|
# ish_miss_prepare wubi-dict
|
||||||
# ish_miss_prepare_learning
|
|
||||||
|
ish_miss_prepare_contexts
|
||||||
|
# ish_miss_prepare_intshell
|
||||||
# ish_miss_prepare_icebergs
|
# ish_miss_prepare_icebergs
|
||||||
# ish_miss_prepare_toolkits
|
# ish_miss_prepare_toolkits
|
||||||
|
# ish_miss_prepare_volcanos
|
||||||
|
# ish_miss_prepare_learning
|
||||||
|
|
||||||
make
|
make
|
||||||
`,
|
`,
|
||||||
|
@ -35,7 +35,7 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
|||||||
m.Info("").Info("%s %s %s", r.Header.Get(ice.MSG_USERIP), r.Method, r.URL)
|
m.Info("").Info("%s %s %s", r.Header.Get(ice.MSG_USERIP), r.Method, r.URL)
|
||||||
|
|
||||||
// 输出日志
|
// 输出日志
|
||||||
if m.Conf(SERVE, "meta.logheaders") == "true" {
|
if m.Conf(SERVE, kit.Keym("logheaders")) == "true" {
|
||||||
for k, v := range r.Header {
|
for k, v := range r.Header {
|
||||||
m.Info("%s: %v", k, kit.Format(v))
|
m.Info("%s: %v", k, kit.Format(v))
|
||||||
}
|
}
|
||||||
@ -57,15 +57,16 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
|||||||
|
|
||||||
// 主页接口
|
// 主页接口
|
||||||
if r.Method == "GET" && r.URL.Path == "/" {
|
if r.Method == "GET" && r.URL.Path == "/" {
|
||||||
msg := m.Spawn()
|
msg, repos := m.Spawn(), ice.INTSHELL
|
||||||
if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") {
|
if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") {
|
||||||
Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, "meta.intshell.path"), m.Conf(SERVE, "meta.intshell.index")))
|
repos = ice.INTSHELL
|
||||||
} else {
|
} else {
|
||||||
|
repos = ice.VOLCANOS
|
||||||
if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) {
|
if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, "meta.volcanos.path"), m.Conf(SERVE, "meta.volcanos.index")))
|
|
||||||
}
|
}
|
||||||
|
Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, kit.Keym(repos, kit.SSH_PATH)), m.Conf(SERVE, kit.Keym(repos, kit.SSH_INDEX))))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 请求地址
|
// 请求地址
|
||||||
msg.Option(ice.MSG_USERWEB, kit.Select(msg.Conf(SHARE, "meta.domain"), r.Header.Get("Referer")))
|
msg.Option(ice.MSG_USERWEB, kit.Select(msg.Conf(SHARE, kit.Keym("domain")), r.Header.Get("Referer")))
|
||||||
msg.Option(ice.MSG_USERUA, r.Header.Get("User-Agent"))
|
msg.Option(ice.MSG_USERUA, r.Header.Get("User-Agent"))
|
||||||
msg.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
|
msg.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
|
||||||
if msg.R, msg.W = r, w; r.Header.Get("X-Real-Port") != "" {
|
if msg.R, msg.W = r, w; r.Header.Get("X-Real-Port") != "" {
|
||||||
@ -201,18 +202,18 @@ func init() {
|
|||||||
SERVE: {Name: SERVE, Help: "服务器", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME,
|
SERVE: {Name: SERVE, Help: "服务器", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME,
|
||||||
tcp.LOCALHOST, true, aaa.BLACK, kit.Dict(), aaa.WHITE, kit.Dict(
|
tcp.LOCALHOST, true, aaa.BLACK, kit.Dict(), aaa.WHITE, kit.Dict(
|
||||||
LOGIN, true, SPACE, true, SHARE, true,
|
LOGIN, true, SPACE, true, SHARE, true,
|
||||||
"volcanos", true, "intshell", true,
|
ice.VOLCANOS, true, ice.INTSHELL, true,
|
||||||
"require", true, "publish", true,
|
ice.REQUIRE, true, ice.PUBLISH, true,
|
||||||
), "logheaders", false,
|
), "logheaders", false,
|
||||||
|
|
||||||
"static", kit.Dict("/", "usr/volcanos/"),
|
kit.SSH_STATIC, kit.Dict("/", "usr/volcanos/"),
|
||||||
"volcanos", kit.Dict("path", "usr/volcanos", "index", "page/index.html",
|
ice.VOLCANOS, kit.Dict(kit.MDB_PATH, "usr/volcanos", kit.SSH_INDEX, "page/index.html",
|
||||||
"repos", "https://github.com/shylinux/volcanos", "branch", "master",
|
kit.SSH_REPOS, "https://github.com/shylinux/volcanos", kit.SSH_BRANCH, "master",
|
||||||
), "publish", "usr/publish/",
|
), ice.PUBLISH, "usr/publish/",
|
||||||
|
|
||||||
"intshell", kit.Dict("path", "usr/intshell", "index", "index.sh",
|
ice.INTSHELL, kit.Dict(kit.MDB_PATH, "usr/intshell", kit.SSH_INDEX, "index.sh",
|
||||||
"repos", "https://github.com/shylinux/intshell", "branch", "master",
|
kit.SSH_REPOS, "https://github.com/shylinux/intshell", kit.SSH_BRANCH, "master",
|
||||||
), "require", ".ish/pluged",
|
), ice.REQUIRE, ".ish/pluged",
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
@ -251,7 +252,7 @@ func init() {
|
|||||||
m.Render(ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, kit.Keym("intshell.path")), path.Join(arg...)))
|
m.Render(ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, kit.Keym("intshell.path")), path.Join(arg...)))
|
||||||
}},
|
}},
|
||||||
"/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) {
|
||||||
_share_local(m, m.Conf(SERVE, kit.Keym("publish")), path.Join(arg...))
|
_share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...))
|
||||||
}},
|
}},
|
||||||
"/require/": {Name: "/require/", Help: "公有云", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/require/": {Name: "/require/", Help: "公有云", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
||||||
|
10
conf.go
10
conf.go
@ -16,6 +16,9 @@ const ( // REPOS
|
|||||||
ICEBERGS = "icebergs"
|
ICEBERGS = "icebergs"
|
||||||
CONTEXTS = "contexts"
|
CONTEXTS = "contexts"
|
||||||
INTSHELL = "intshell"
|
INTSHELL = "intshell"
|
||||||
|
|
||||||
|
PUBLISH = "publish"
|
||||||
|
REQUIRE = "require"
|
||||||
)
|
)
|
||||||
const ( // DIR
|
const ( // DIR
|
||||||
ETC_MISS = "etc/miss.sh"
|
ETC_MISS = "etc/miss.sh"
|
||||||
@ -23,6 +26,9 @@ const ( // DIR
|
|||||||
ETC_EXIT = "etc/exit.shy"
|
ETC_EXIT = "etc/exit.shy"
|
||||||
SRC_MAIN = "src/main.shy"
|
SRC_MAIN = "src/main.shy"
|
||||||
SRC_MAIN_GO = "src/main.go"
|
SRC_MAIN_GO = "src/main.go"
|
||||||
|
SRC_VERSION = "src/version.go"
|
||||||
|
SRC_BINPACK = "src/binpack.go"
|
||||||
|
BIN_BOOTLOG = "bin/boot.log"
|
||||||
BIN_ICE_BIN = "bin/ice.bin"
|
BIN_ICE_BIN = "bin/ice.bin"
|
||||||
BIN_ICE = "bin/ice.sh"
|
BIN_ICE = "bin/ice.sh"
|
||||||
MAKEFILE = "makefile"
|
MAKEFILE = "makefile"
|
||||||
@ -30,6 +36,10 @@ const ( // DIR
|
|||||||
ORDER_JS = "order.js"
|
ORDER_JS = "order.js"
|
||||||
GO_MOD = "go.mod"
|
GO_MOD = "go.mod"
|
||||||
GO_SUM = "go.sum"
|
GO_SUM = "go.sum"
|
||||||
|
|
||||||
|
CTX_DEV = "ctx_dev"
|
||||||
|
CTX_PID = "ctx_pid"
|
||||||
|
CTX_LOG = "ctx_log"
|
||||||
)
|
)
|
||||||
const ( // MSG
|
const ( // MSG
|
||||||
MSG_DETAIL = "detail"
|
MSG_DETAIL = "detail"
|
||||||
|
@ -8,19 +8,17 @@ import (
|
|||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _autogen_script(m *ice.Message, dir string) {
|
func _autogen_script(m *ice.Message, dir string) {
|
||||||
if b, e := kit.Render(m.Conf(AUTOGEN, kit.Keym(SHY)), m); m.Assert(e) {
|
if b, e := kit.Render(m.Conf(AUTOGEN, kit.Keym(SHY)), m); m.Assert(e) {
|
||||||
m.Cmd(nfs.SAVE, dir, string(b))
|
m.Cmd(nfs.DEFS, dir, string(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _autogen_source(m *ice.Message, name string) {
|
func _autogen_source(m *ice.Message, name string) {
|
||||||
m.Cmd(nfs.PUSH, path.Join(kit.SSH_SRC, kit.Keys(kit.MDB_MAIN, SHY)),
|
m.Cmd(nfs.PUSH, ice.SRC_MAIN, "\n", kit.SSH_SOURCE+` `+path.Join(name, kit.Keys(name, SHY)), "\n")
|
||||||
"\n", kit.SSH_SOURCE+` `+path.Join(name, kit.Keys(name, SHY)), "\n")
|
|
||||||
}
|
}
|
||||||
func _autogen_module(m *ice.Message, dir string, ctx string, from string) (list []string) {
|
func _autogen_module(m *ice.Message, dir string, ctx string, from string) (list []string) {
|
||||||
name, value := "", ""
|
name, value := "", ""
|
||||||
@ -67,7 +65,7 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _autogen_version(m *ice.Message) {
|
func _autogen_version(m *ice.Message) {
|
||||||
file := "src/version.go"
|
file := ice.SRC_VERSION
|
||||||
m.Cmd(nfs.SAVE, file, kit.Format(`package main
|
m.Cmd(nfs.SAVE, file, kit.Format(`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -91,17 +89,19 @@ func init() {
|
|||||||
strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "describe", "--tags")),
|
strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "describe", "--tags")),
|
||||||
ice.Info.HostName, ice.Info.UserName,
|
ice.Info.HostName, ice.Info.UserName,
|
||||||
))
|
))
|
||||||
m.Cmdy(nfs.DIR, "src/binpack.go", "time,size,line,path")
|
defer m.Cmdy(nfs.CAT, file)
|
||||||
|
|
||||||
m.Cmdy(nfs.DIR, file, "time,size,line,path")
|
m.Cmdy(nfs.DIR, file, "time,size,line,path")
|
||||||
m.Cmdy(nfs.CAT, file)
|
m.Cmdy(nfs.DIR, ice.SRC_BINPACK, "time,size,line,path")
|
||||||
|
m.Cmdy(nfs.DIR, ice.SRC_MAIN_GO, "time,size,line,path")
|
||||||
}
|
}
|
||||||
func _autogen_miss(m *ice.Message) {
|
func _autogen_miss(m *ice.Message) {
|
||||||
file := "etc/miss.sh"
|
m.Cmd(nfs.DEFS, ice.ETC_MISS, m.Conf(web.DREAM, kit.Keym("miss")))
|
||||||
if _, e := os.Stat(file); os.IsNotExist(e) {
|
defer m.Cmdy(nfs.CAT, ice.ETC_MISS)
|
||||||
m.Cmd(nfs.SAVE, file, m.Conf(web.DREAM, kit.Keym("miss")))
|
|
||||||
}
|
m.Cmdy(nfs.DIR, ice.ETC_MISS, "time,size,line,path")
|
||||||
m.Cmdy(nfs.DIR, file, "time,size,line,path")
|
m.Cmdy(nfs.DIR, ice.GO_MOD, "time,size,line,path")
|
||||||
m.Cmdy(nfs.CAT, file)
|
m.Cmdy(nfs.DIR, ice.GO_SUM, "time,size,line,path")
|
||||||
}
|
}
|
||||||
|
|
||||||
const AUTOGEN = "autogen"
|
const AUTOGEN = "autogen"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user