From 03df7160a2f05fcc35991df25d3b10a52a1b6b9d Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 4 Nov 2019 01:10:43 +0800 Subject: [PATCH] add alpine --- Makefile | 2 + src/contexts/cli/cli.go | 2 +- src/contexts/ctx/type.go | 6 +- src/contexts/nfs/nfs.go | 2 +- src/examples/code/code.go | 23 +++++- src/plugin/docker/index.shy | 14 +++- usr/librarys/example.js | 4 +- usr/librarys/toolkit.js | 3 + usr/local/wiki/自然/编程/终端工具链/alpine.md | 79 +++++++++++++++++++ 9 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 usr/local/wiki/自然/编程/终端工具链/alpine.md diff --git a/Makefile b/Makefile index 3db7978a..dad2afc7 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ prepare: @go get github.com/skip2/go-qrcode @go get gopkg.in/gomail.v2 +linux: + GOOS=linux $(BUILD)$(TARGET).linux.$(shell go env GOARCH) $(BENCH) linux_arm: GOARCH=arm GOOS=linux $(BUILD)$(TARGET).linux.arm $(BENCH) linux32: diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index 74056345..0a3518dd 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -160,7 +160,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", }, }, Help: "运行环境, host, init, boot, node, user, work"}, "system": &ctx.Config{Name: "system", Value: map[string]interface{}{ - "timeout": "60s", + "timeout": "180s", "env": map[string]interface{}{}, "shell": map[string]interface{}{ "sh": map[string]interface{}{"cmd": "bash"}, diff --git a/src/contexts/ctx/type.go b/src/contexts/ctx/type.go index 790dc7df..8ba6ad1e 100644 --- a/src/contexts/ctx/type.go +++ b/src/contexts/ctx/type.go @@ -613,8 +613,12 @@ func (m *Message) Cmd(args ...interface{}) *Message { } else if strings.Contains(key, ".") { arg := strings.Split(key, ".") - if msg, key = msg.Sess(arg[0]), arg[1]; msg != nil { + if msg, key = m.Sess(arg[0]), arg[1]; msg != nil { msg.Option("remote_code", "") + + } else if msg, key = m.Find(strings.Join(arg[0:len(arg)-1], "."), true), arg[len(arg)-1]; msg != nil { + msg.Option("remote_code", "") + } } if msg == nil { diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index d212b9a4..bfe33dd7 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -50,7 +50,7 @@ func dir(m *ctx.Message, root string, name string, level int, deep bool, dir_typ if f, e = os.Lstat(p); e != nil { m.Log("info", "%s", e) continue - } else if (f.Mode() & os.ModeSymlink) != 0 { + } else if (f.Mode()&os.ModeSymlink) != 0 && f.IsDir() { continue } diff --git a/src/examples/code/code.go b/src/examples/code/code.go index c5e7e421..50ad0c95 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -33,8 +33,20 @@ CMD sh bin/boot.sh Help: "终端", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { p, arg := kit.Select(".", arg[0]), arg[1:] switch arg[0] { - case "install": - m.Cmd("cli.system", "apk", "add", arg[1]) + case "init": + m.Cmd("cli.system", "apk", "update") + switch arg[1] { + case "build": + m.Cmd("cli.system", "apk", "add", "nginx") + m.Cmd("cli.system", "apk", "add", "redis") + m.Cmd("cli.system", "apk", "add", "tmux") + m.Cmd("cli.system", "apk", "add", "zsh") + m.Cmd("cli.system", "apk", "add", "git") + m.Cmd("cli.system", "apk", "add", "vim") + m.Cmd("cli.system", "apk", "add", "build-base") + m.Cmd("cli.system", "apk", "add", "golang") + m.Cmd("cli.system", "apk", "add", "mysql") + } case "list": m.Cmdy("nfs.dir", p, "time", "size", "path") @@ -84,6 +96,8 @@ CMD sh bin/boot.sh case "tail": m.Cmdy("cli.system", "tail", path.Join(p, arg[1])) + default: + m.Cmdy("cli.system", arg) } return }}, @@ -295,6 +309,11 @@ CMD sh bin/boot.sh return }}, "git": {Name: "git", Help: "版本", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + prefix := []string{"cli.system", "git"} + switch arg[0] { + case "init": + m.Cmdy(prefix, "config", "alias.s", "status") + } m.Echo("git") return }}, diff --git a/src/plugin/docker/index.shy b/src/plugin/docker/index.shy index 7280bc31..ac602af3 100644 --- a/src/plugin/docker/index.shy +++ b/src/plugin/docker/index.shy @@ -1,6 +1,7 @@ -kit shell "命令" private "web.code.zsh" \ +kit shell "命令" private "ssh._route" _ "context" "find" "web.code" "zsh" \ + text "" name pod imports plugin_pod \ text "" name dir imports plugin_path action auto \ - select "" name cmd values list values find values grep values tail \ + select "" name cmd values list values find values grep values tail values init \ exports path path \ text "" name txt \ feature display editor \ @@ -29,7 +30,7 @@ kit image "镜像" private "web.code.docker" "image" \ text "" name tag imports plugin_TAG \ exports IMAGE_ID IMAGE_ID "" REPOSITORY REPOSITORY "" TAG TAG "" \ feature detail "运行" "删除" "清理" \ - button "查看" action auto + button "查看" kit container "容器" private "web.code.docker" "container" \ text "" name arg imports plugin_CONTAINER_ID \ @@ -37,10 +38,15 @@ kit container "容器" private "web.code.docker" "container" \ feature detail "进入" "停止" "启动" "重启" "修改" "删除" "清理" \ button "查看" action auto +kit command "命令" private "web.code.docker" "container" \ + text "" name tag imports plugin_CONTAINER_ID \ + text "pwd" name cmd view long \ + button "执行" + kit network "网络" private "web.code.docker" "network" \ text "" name arg imports plugin_NETWORK_ID action auto \ exports NETWORK_ID NETWORK_ID \ - button "查看" action auto + button "查看" kit volume "存储" private "web.code.docker" "volume" \ text "" name arg imports plugin_CONTAINER_ID \ diff --git a/usr/librarys/example.js b/usr/librarys/example.js index 717ef075..1ace51ff 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -1220,7 +1220,7 @@ function Plugin(page, pane, field, inits, runs) { var meta = arguments.callee.meta var list = arguments.callee.list - for (var i = 0; i < list.length; i += 3) {if (list[i+1] == name) { + for (var i = 0; i < list.length; i += 3) {if (list[i+1] == name || list[i+2]) { for (var i = 0; i < list.length; i += 3) { page.Sync("plugin_"+list[i]).set(meta[list[i+2]||""](list[i+1]? line[list[i+1]]: value, list[i+1]||name, line, list)) } @@ -1487,7 +1487,7 @@ function Output(plugin, type, msg, cb, target, option) { }, inner: function(msg, cb) { target.innerHTML = "", plugin.onfigure.meta.max(target) - output.onimport.meta._table(msg, msg.append) || (target.innerHTML = msg.result.join("")) + output.onimport.meta._table(msg, msg.append) || kit.OrderCode(kit.ModifyNode(target, msg.result.join(""))) kit._call(cb, [msg]) }, code: function(msg, cb) { diff --git a/usr/librarys/toolkit.js b/usr/librarys/toolkit.js index b519f938..6e34ca0d 100644 --- a/usr/librarys/toolkit.js +++ b/usr/librarys/toolkit.js @@ -386,6 +386,9 @@ kit = toolkit = (function() {var kit = {__proto__: document, // HTML显示文本 OrderCode: function(code) {if (!code) {return} code.onclick = function(event) {kit.CopyText()} + kit.Selector(code, "a", function(item) { + item.target = "_blank" + }) }, OrderLink: function(link) {link.target = "_blank"}, OrderText: function(pane, text) { diff --git a/usr/local/wiki/自然/编程/终端工具链/alpine.md b/usr/local/wiki/自然/编程/终端工具链/alpine.md new file mode 100644 index 00000000..c0d6cf7c --- /dev/null +++ b/usr/local/wiki/自然/编程/终端工具链/alpine.md @@ -0,0 +1,79 @@ +## alpine + +- 官网: https://www.alpinelinux.org/ +- 文档: https://wiki.alpinelinux.org/ +- 源码: https://github.com/alpinelinux/docker-alpine +- 博客: https://blog.csdn.net/zl1zl2zl3/article/details/80118001 + +## 安装 + +``` +docker run alpine -it pwd +``` + +## 安装 +### 主机名 +``` +$ echo myos > /etc/hostname +$ hostname -F /etc/hostname +$ sed -i -r 's#127.0.0.1.*#127.0.0.1 myos#g' /etc/hosts +$ /etc/resolv.conf +``` + +### 网络配置 +``` +$ ip +$ ping +$ udhcpc +$ ifconfig +$ /etc/network/interfaces +auto lo +iface lo inet lookback +auto eth0 +iface eth0 inet dhcp +iface eth1 inet static +iface eth1 inet static + address 192.168.1.21 + netmask 255.255.0.0 + gateway 192.168.1.1 + +$ wpa_supplicant +$ /etc/wpa_supplicant/wpa_supplicant.conf +``` + +### 包工具 +``` +/etc/apk/repositories +/var/cache/apk +/etc/apk/world +$ apk +$ apk update +$ apk search +$ apk cache +$ apk info +$ apk add +$ apk del +``` + +### 开发环境 + +``` +$ apk update +$ apk add build-base +``` + +``` +/* vi hi.c */ +#include + +int main(int argc, char *argv[]) { + println("hello c world!"); +} +``` + +``` +$ gcc hi.c -o hi +$ ./hi +hello c world! +``` +