mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
add coder
This commit is contained in:
parent
82c33e211b
commit
3d0dd2c8cd
@ -56,6 +56,7 @@ func _daemon_exec(m *ice.Message, cmd *exec.Cmd) {
|
||||
kit.Close(m.Optionv(p))
|
||||
}
|
||||
})
|
||||
m.Sleep("100ms")
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -82,7 +82,8 @@ func _system_find(m *ice.Message, bin string, dir ...string) string {
|
||||
return bin
|
||||
}
|
||||
if strings.HasPrefix(bin, nfs.PWD) {
|
||||
return kit.Path(m.Option(CMD_DIR), bin)
|
||||
// return kit.Path(m.Option(CMD_DIR), bin)
|
||||
return bin
|
||||
}
|
||||
if len(dir) == 0 {
|
||||
dir = append(dir, strings.Split(kit.Env(PATH), ice.DF)...)
|
||||
|
@ -94,7 +94,7 @@ func _spide_list(m *ice.Message, arg ...string) {
|
||||
return
|
||||
}
|
||||
|
||||
if true || m.Config(LOGHEADERS) == ice.TRUE {
|
||||
if m.Config(LOGHEADERS) == ice.TRUE {
|
||||
for k, v := range res.Header {
|
||||
m.Debug("%v: %v", k, v)
|
||||
}
|
||||
|
@ -98,7 +98,10 @@ func _install_spawn(m *ice.Message, arg ...string) {
|
||||
nfs.MkdirAll(m, target)
|
||||
defer m.Echo(target)
|
||||
|
||||
m.Cmd(nfs.DIR, path.Join(source, kit.Select("_install", m.Option(INSTALL)))).Tables(func(value map[string]string) {
|
||||
if m.Option(INSTALL) == "" && kit.FileExists(kit.Path(source, "_install")) {
|
||||
m.Option(INSTALL, "_install")
|
||||
}
|
||||
m.Cmd(nfs.DIR, path.Join(source, m.Option(INSTALL))).Tables(func(value map[string]string) {
|
||||
m.Cmd(cli.SYSTEM, "cp", "-r", strings.TrimSuffix(value[nfs.PATH], ice.PS), target+ice.PS)
|
||||
})
|
||||
}
|
||||
@ -124,7 +127,12 @@ func _install_service(m *ice.Message, arg ...string) {
|
||||
m.Set(tcp.PORT).Tables(func(value map[string]string) { m.Push(tcp.PORT, path.Base(value[nfs.DIR])) })
|
||||
}
|
||||
func _install_stop(m *ice.Message, arg ...string) {
|
||||
m.Cmd(cli.SYSTEM, "kill", m.Option("pid"))
|
||||
m.Cmd(cli.DAEMON).Tables(func(value map[string]string) {
|
||||
if value[cli.PID] == m.Option(cli.PID) {
|
||||
m.Cmd(cli.DAEMON, cli.STOP, kit.Dict(mdb.HASH, value[mdb.HASH]))
|
||||
}
|
||||
})
|
||||
m.Cmd(cli.SYSTEM, cli.KILL, m.Option(cli.PID))
|
||||
}
|
||||
|
||||
const (
|
||||
@ -142,6 +150,11 @@ func init() {
|
||||
web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
_install_download(m)
|
||||
}},
|
||||
nfs.SOURCE: {Name: "source link path", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, path.Join(m.Config(nfs.PATH), kit.TrimExt(m.Option(mdb.LINK)), "_install"))
|
||||
defer m.StatusTime(nfs.PATH, m.Option(nfs.DIR_ROOT))
|
||||
m.Cmdy(nfs.DIR, m.Option(nfs.PATH))
|
||||
}},
|
||||
cli.BUILD: {Name: "build link", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
if err := _install_build(m, arg...); err != "" {
|
||||
m.ToastFailure(cli.BUILD)
|
||||
@ -162,11 +175,6 @@ func init() {
|
||||
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
_install_stop(m, arg...)
|
||||
}},
|
||||
nfs.SOURCE: {Name: "source link path", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, path.Join(m.Config(nfs.PATH), kit.TrimExt(m.Option(mdb.LINK)), "_install"))
|
||||
defer m.StatusTime(nfs.PATH, m.Option(nfs.DIR_ROOT))
|
||||
m.Cmdy(nfs.DIR, m.Option(nfs.PATH))
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch len(arg) {
|
||||
case 0: // 源码列表
|
||||
|
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.11
|
||||
|
||||
require (
|
||||
shylinux.com/x/go-qrcode v0.0.1
|
||||
shylinux.com/x/ice v0.9.8
|
||||
shylinux.com/x/toolkits v0.6.0
|
||||
shylinux.com/x/websocket v0.0.1
|
||||
)
|
||||
|
3
go.sum
3
go.sum
@ -1,5 +1,8 @@
|
||||
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
||||
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||
shylinux.com/x/ice v0.9.8 h1:SJCJZ5ZGgFEg8SXDwASDNEY/QLEeJLDwC42MDOIBi90=
|
||||
shylinux.com/x/ice v0.9.8/go.mod h1:bx0QwDuu5Uhe1W6fMWnJBiezmQAL0i/U3B5HJK6HzCU=
|
||||
shylinux.com/x/icebergs v1.2.5/go.mod h1:4lRksPmw+2xtXe3NrAAs9hBI4R4/AbpppqTPR3HSD2c=
|
||||
shylinux.com/x/toolkits v0.6.0 h1:DqTQOj7CA6jc7x9kd9uxX0NGCHYo67V6NmOmINqP+Is=
|
||||
shylinux.com/x/toolkits v0.6.0/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||
shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE=
|
||||
|
5
misc.go
5
misc.go
@ -285,6 +285,7 @@ func SplitCmd(name string) (list []interface{}) {
|
||||
TEXT = "text"
|
||||
ARGS = "args"
|
||||
TEXTAREA = "textarea"
|
||||
PASSWORD = "password"
|
||||
SELECT = "select"
|
||||
BUTTON = "button"
|
||||
)
|
||||
@ -313,6 +314,10 @@ func SplitCmd(name string) (list []interface{}) {
|
||||
item = kit.Dict(TYPE, TEXTAREA, NAME, ls[i])
|
||||
list = append(list, item)
|
||||
|
||||
case "password":
|
||||
item = kit.Dict(TYPE, PASSWORD, NAME, ls[i])
|
||||
list = append(list, item)
|
||||
|
||||
case ":":
|
||||
if item[TYPE] = kit.Select("", ls, i+1); item[TYPE] == BUTTON {
|
||||
button = true
|
||||
|
14
misc/coder/coder.shy
Normal file
14
misc/coder/coder.shy
Normal file
@ -0,0 +1,14 @@
|
||||
chapter "codeserver"
|
||||
refer `
|
||||
https://coder.com/
|
||||
https://github.com/coder/code-server/
|
||||
https://github.com/microsoft/vscode
|
||||
https://code.visualstudio.com/
|
||||
`
|
||||
|
||||
spark shell `
|
||||
wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz
|
||||
tar xvf code-server-4.4.0-linux-amd64.tar.gz
|
||||
cd code-server-4.4.0-linux-amd64
|
||||
./bin/code-server
|
||||
`
|
47
misc/coder/server.go
Normal file
47
misc/coder/server.go
Normal file
@ -0,0 +1,47 @@
|
||||
package coder
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
type server struct {
|
||||
ice.Code
|
||||
linux string `data:"https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz"`
|
||||
darwin string `data:"https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-macos-amd64.tar.gz"`
|
||||
source string `data:"https://github.com/coder/code-server/archive/refs/tags/v4.4.0.tar.gz"`
|
||||
password string `data:"1234"`
|
||||
|
||||
start string `name:"start port host password" help:"启动"`
|
||||
list string `name:"list port path auto start install" help:"编辑器"`
|
||||
}
|
||||
|
||||
func (s server) Start(m *ice.Message, arg ...string) {
|
||||
s.Code.Start(m, "", "./bin/code-server", func(p string) []string {
|
||||
return []string{kit.Format("--config=%s", m.Cmdx(nfs.SAVE, kit.Path(p, "config"), kit.Format(`
|
||||
user-data-dir: %s
|
||||
bind-addr: %s:%s
|
||||
password: %s
|
||||
`, "./data", kit.Select("0.0.0.0", m.Option(tcp.HOST)), path.Base(p), kit.Select(m.Config(aaa.PASSWORD), m.Option(aaa.PASSWORD))))), kit.Path(nfs.PWD)}
|
||||
})
|
||||
}
|
||||
func (s server) List(m *ice.Message, arg ...string) {
|
||||
if s.Code.List(m, "", arg...); len(arg) == 0 {
|
||||
s.PushLink(m).Tables(func(value map[string]string) {
|
||||
switch value[cli.STATUS] {
|
||||
case cli.START:
|
||||
m.PushButton(s.Open, s.Stop)
|
||||
default:
|
||||
m.PushButton("")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(server{}) }
|
Loading…
x
Reference in New Issue
Block a user