1
0
forked from x/ContextOS

opt contexts

This commit is contained in:
shaoying 2020-12-02 16:10:09 +08:00
parent 1eb2ee8df1
commit d31be53ddf
18 changed files with 3 additions and 534 deletions

View File

@ -5,6 +5,7 @@ export CGO_ENABLED=0
all: all:
@echo && date @echo && date
go build -v -o bin/ice.bin src/main.go && chmod u+x bin/ice.bin && ./bin/ice.sh restart go build -v -o bin/ice.bin src/main.go && chmod u+x bin/ice.bin && ./bin/ice.sh restart
relay: src/relay.go relay: src/relay.go
@echo && date @echo && date
go build -v -o usr/publish/$@ src/$@.go && chmod u+x usr/publish/$@ go build -v -o usr/publish/$@ src/$@.go && chmod u+x usr/publish/$@

View File

@ -12,18 +12,10 @@ ice>
``` ```
open http://localhost:9020 open http://localhost:9020
### install by docker
```
$ docker run -p 9020:9020 -it shylinux/contexts
ice>
```
open http://localhost:9020
### install by source ### install by source
``` ```
$ git clone https://github.com/shylinux/contexts $ git clone https://github.com/shylinux/contexts
$ cd contexts && source etc/miss.sh $ cd contexts && source etc/miss.sh
$ make
$ ish_miss_serve $ ish_miss_serve
ice> ice>
``` ```

View File

@ -1,106 +0,0 @@
#! /bin/bash -i
# 日志配置
export ctx_err=${ctx_err:="/dev/null"}
export ctx_log=${ctx_log:="var/log"}
export ctx_log_debug=${ctx_log_debug:=false}
export ctx_log_disable=${ctx_log_disable:=false}
export ctx_gdb_enable=${ctx_gdb_enable:=false}
# 目录配置
export ctx_app=${ctx_app:="shy"}
export ctx_bin=${ctx_bin:=$(pwd)/bin/${ctx_app}}; [ -e $ctx_bin ] || export ctx_bin=`which ${ctx_app}`
export ctx_root=${ctx_root:=/usr/local/context}
export ctx_home=${ctx_home:=~/context}
# 网络配置
export ctx_cas=${ctx_cas:=""}
export ctx_ups=${ctx_ups:=""}
export ctx_box=${ctx_box:=""}
export ctx_dev=${ctx_dev:="https://shylinux.com"}
# 服务配置
export ctx_type=${ctx_type:="node"}
export ssh_port=${ssh_port:=":9090"}
export web_port=${web_port:=":9095"}
# 用户配置
export node_cert=${node_cert:=""}
export node_key=${node_key:=""}
export HOSTNAME=${HOSTNAME:=""}
export USER=${USER:=""}
export PWD=${PWD:=""}
install() {
if [ -n "$1" ]; then mkdir $1; cd $1; shift; fi
md5=md5sum
case `uname -s` in
"Darwin") GOOS=darwin md5=md5;;
"Linux") GOOS=linux;;
*) GOOS=windows;;
esac
case `uname -m` in
"x86_64") GOARCH=amd64;;
"armv7l") GOARCH=arm;;
*) GOARCH=386;;
esac
echo
echo
which wget && get="wget -q -O" || get="curl -o"
$get ${ctx_app} "$ctx_dev/publish/bench?GOOS=$GOOS&GOARCH=$GOARCH" && chmod a+x ${ctx_app} || return
target=install && [ -n "$1" ] && target=$1
${md5} ${ctx_app} && $(pwd)/${ctx_app} upgrade ${target} || return
mv ${ctx_app} bin/${ctx_app}
# && bin/boot.sh
}
main() {
trap HUP hup
log "\nstarting..."
while true; do
date && ${ctx_bin} "$@" 2>>${ctx_err} && break
log "\n\nrestarting..." && sleep 1
done
}
action() {
pid=$(cat var/run/bench.pid)
log "kill" $1 $pid && kill -$1 ${pid}
}
hup() { echo "term hup"; }
log() { echo -e $*; }
log "bin: $ctx_bin"
log "box: $ctx_box"
log "dev: $ctx_dev"
log "ups: $ctx_ups"
case $1 in
help) echo
echo " >>>> welcome context world! <<<<"
echo
echo "more info see https://github.com/shylinux/context"
echo
echo " install [dir [type]] 安装并启动服务"
echo " [start] 启动服务"
echo " create dir 创建并启动服务"
echo " restart 重启服务"
echo " upgrade 升级服务"
echo " quit 保存并停止服务"
echo " term 停止服务"
;;
install) shift && install "$@";;
installs) shift && install "$@" && bin/boot.sh ;;
start) shift && main "$@";;
"") main "$@";;
create) mkdir -p $2; cd $2 && shift && shift && main "$@";;
restart) action 30;;
upgrade) action 31;;
quit) action QUIT;;
term) action TERM
esac

View File

@ -1,5 +0,0 @@
#! /bin/bash
export ctx_box=${ctx_box:="http://localhost:9095"}
[ -f bin/boot.sh ] && source bin/boot.sh || source boot.sh

View File

@ -1,189 +0,0 @@
#! /bin/sh
ice_sh="bin/ice.sh"
ice_bin="bin/ice.bin"
ice_mod="${PWD##**/}"
init_shy="etc/init.shy"
local_shy="etc/local.shy"
exit_shy="etc/exit.shy"
main_go="src/main.go"
main_js="src/main.js"
readme="README.md"
shy="src/main.shy"
prepare() {
[ -d src ] || mkdir src
[ -f ${main_go} ] || cat >> ${main_go} <<END
package main
import (
"github.com/shylinux/icebergs"
_ "github.com/shylinux/icebergs/base"
_ "github.com/shylinux/icebergs/core"
_ "github.com/shylinux/icebergs/misc"
)
func main() { println(ice.Run()) }
END
[ -f ${shy} ] || cat >> ${shy} <<END
title "${ice_mod}"
field "自动化" favor
field "启动流程" favor args "启动流程"
field "请求响应" favor args "请求响应"
field "服务集群" favor args "服务集群"
field "数据结构" favor args "数据结构"
field "系统架构" favor args "系统架构"
field "编译原理" favor args "编译原理"
END
[ -f ${main_js} ] || cat >> ${main_js} <<END
Volcanos("onimport", {help: "导入数据", list: [],
"init": function(can, msg, cb, output, action, option) {},
})
Volcanos("onaction", {help: "控件菜单", list: []})
Volcanos("onchoice", {help: "控件交互", list: ["刷新"]
"刷新": function(event, can, value, cmd, target) {},
})
Volcanos("ondetail", {help: "控件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})
END
[ -f go.mod ] || go mod init ${ice_mod}
[ -f Makefile ] || cat >> Makefile <<END
export GOPROXY=https://goproxy.cn
export GOPRIVATE=github.com
export CGO_ENABLED=0
all:
@echo && date
go build -o ${ice_bin} ${main_go} && chmod u+x ${ice_bin} && ./${ice_sh} restart
END
[ -d etc ] || mkdir etc
[ -f ${init_shy} ] || cat >> ${init_shy} <<END
~web
~ssh
source etc/local.shy
END
[ -f ${local_shy} ] || cat >> ${local_shy} <<END
~aaa
~web
END
[ -f ${exit_shy} ] || cat >> "${exit_shy}" <<END
~web
END
[ -d bin ] || mkdir bin
[ -f ${ice_sh} ] || cat >> ${ice_sh} <<END
#! /bin/sh
export PATH=\${PWD}/bin:\${PWD}:\$PATH
export ctx_pid=\${ctx_pid:=var/run/ice.pid}
export ctx_log=\${ctx_log:=bin/boot.log}
export ctx_mod=\${ctx_mod:="gdb,log,ssh,ctx"}
prepare() {
[ -d bin ] || mkdir bin
[ -e ${ice_sh} ] || curl \$ctx_dev/publish/ice.sh -o ${ice_sh} && chmod u+x ${ice_sh}
[ -e ${ice_bin} ] && chmod u+x ${ice_bin} && return
bin="ice"
case \`uname -s\` in
Darwin) bin=\${bin}.darwin ;;
Linux) bin=\${bin}.linux ;;
*) bin=\${bin}.windows ;;
esac
case \`uname -m\` in
x86_64) bin=\${bin}.amd64 ;;
i686) bin=\${bin}.386 ;;
arm*) bin=\${bin}.arm ;;
esac
curl \$ctx_dev/publish/\${bin} -o ${ice_bin} && chmod u+x ${ice_bin}
}
start() {
trap HUP hup && while true; do
date && ice.bin \$@ 2>\$ctx_log && echo -e "\n\nrestarting..." || break
done
}
restart() {
[ -e \$ctx_pid ] && kill -2 \`cat \$ctx_pid\` || echo
}
shutdown() {
[ -e \$ctx_pid ] && kill -3 \`cat \$ctx_pid\` || echo
}
serve() {
prepare && shutdown && start \$@
}
cmd=\$1 && [ -n "\$cmd" ] && shift || cmd=serve
\$cmd \$*
END
chmod u+x ${ice_sh}
}
build() {
export CGO_ENABLED=0
export GOPRIVATE=github.com
export GOPROXY=https://goproxy.cn
miss=./ && [ "$1" != "" ] && miss=$1 && shift && mkdir $miss
cd $miss && prepare && go build -o ${ice_bin} ${main_go} && chmod u+x ${ice_bin} && ./${ice_sh} start serve
}
tutor() {
[ -d $1 ] || mkdir $1
[ -f "$1/$1.js" ] || cat >> "$1/$1.js" <<END
Volcanos("onimport", {help: "导入数据", list: [],
"init": function(can, msg, cb, output, action, option) {},
})
Volcanos("onaction", {help: "控件菜单", list: []})
Volcanos("onchoice", {help: "控件交互", list: ["刷新"]
"刷新": function(event, can, value, cmd, target) {},
})
Volcanos("ondetail", {help: "控件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})
END
[ -f "$1/$1.shy" ] || cat >> "$1/$1.shy" <<END
title "$1"
END
[ -f "$1/$1.go" ] || cat >> "$1/$1.go" <<END
package $1
import (
"github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/core/wiki"
"github.com/shylinux/toolkits"
)
var Index = &ice.Context{Name: "$1", Help: "$1",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
"$1": {Name: "$1", Help: "$1", Value: kit.Data(kit.MDB_SHORT, "name")},
},
Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
"$1": {Name: "$1", Help: "$1", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Echo("hello world")
}},
},
}
func init() { wiki.Index.Register(Index, nil) }
END
ls -l $1
}
cmd=build && [ "$1" != "" ] && cmd=$1 && shift
$cmd $*

View File

@ -1,6 +0,0 @@
#! /bin/bash
export ctx_type=user
[ -f bin/boot.sh ] && source bin/boot.sh || source boot.sh

View File

@ -1,9 +0,0 @@
#! /bin/bash
export ctx_ups=-
export ctx_box=-
export ctx_dev=-
export ctx_type=work
[ -f bin/boot.sh ] && source bin/boot.sh || source boot.sh

View File

@ -1,46 +0,0 @@
PUBLISH=usr/publish
BENCH=src/extend/shy.go
BUILD=go build -o $(PUBLISH)/
TARGET=shy
install:prepare
GOPATH=$(PWD):$(GOPATH) go install $(BENCH) && date && echo
@bin/boot.sh restart && date
prepare:
@go get github.com/shylinux/icebergs
@go get github.com/shylinux/toolkits
@go get github.com/nsf/termbox-go
@go get github.com/gorilla/websocket
@go get github.com/go-sql-driver/mysql
@go get github.com/gomodule/redigo/redis
@go get github.com/gomarkdown/markdown
@go get github.com/skip2/go-qrcode
@go get gopkg.in/gomail.v2
gotags:
gotags -f golang.tags -R $(GOROOT)/src
tags:
gotags -f ctx.tags -R src
tool:
go get github.com/nsf/gocode
go get github.com/jstemmer/gotags
# go get github.com/bradfitz/goimports
go get github.com/Go-zh/tools/cmd/gopls
linux:
GOPATH=$(PWD):$(GOPATH) GOOS=linux $(BUILD)$(TARGET).linux.$(shell go env GOARCH) $(BENCH)
linux_arm:
GOARCH=arm GOOS=linux $(BUILD)$(TARGET).linux.arm $(BENCH)
linux32:
GOARCH=386 GOOS=linux $(BUILD)$(TARGET).linux.386 $(BENCH)
linux64:
GOARCH=amd64 GOOS=linux $(BUILD)$(TARGET).linux.amd64 $(BENCH)
darwin:
GOARCH=amd64 GOOS=darwin $(BUILD)$(TARGET).darwin.amd64 $(BENCH)
win64:
GOARCH=amd64 GOOS=windows $(BUILD)$(TARGET).win64.exe $(BENCH)
win32:
GOARCH=386 GOOS=windows $(BUILD)$(TARGET).win32.exe $(BENCH)

View File

@ -1,13 +0,0 @@
#!/bin/sh
export GOPATH=~/bin/go
export GOROOT=~/usr/local/go
export GOPRIVATE=git.zuoyebang.cc,github.com
ISH_CONF_WORK=~/usr/local/work
if [ -f ~/.ish/plug.sh ] && source ~/.ish/plug.sh; then
require conf.sh
ish_ctx_cli_prompt
fi

View File

@ -1,6 +0,0 @@
~cli
upgrade plugin context
upgrade plugin storage
upgrade plugin love
upgrade plugin mind

View File

@ -1,21 +0,0 @@
# 应用配置
~chat
config save var/tmp/share.json share
~wiki
config save var/tmp/story.json story
~code
config save var/tmp/vim.json vim
config save var/tmp/zsh.json zsh
config save var/tmp/dream.json dream
config save var/tmp/code.json login
# 系统配置
~ssh
config save var/data/flow.json flow
config save var/data/work.json work
~aaa
config save var/tmp/auth.json auth
config save var/tmp/short.json short
~cli
config save var/tmp/runtime.json runtime

View File

@ -1,24 +0,0 @@
[user]
name = shaoying
email = shylinux@icloud.com
[color]
ui = always
[alias]
s = status
l = log --pretty=format:\"%C(4)%h %C(6)%ad %C(4)%an %C(6)%ar %C(4)%d %n%C(7)%s\" --date=\"format:%m/%d %R\" --shortstat --graph
b = branch
r = remote
m = merge
t = tag
i = commit
o = checkout
d = diff
a = add
am = commit -a -m
[receive]
denyCurrentBranch = ignore
[core]
editor = vim
ignorecase = true
[merge]
tool = vimdiff

View File

@ -1,34 +0,0 @@
# 系统配置
~cli
config load tmp/runtime.json runtime
~aaa
config load tmp/short.json short
config load tmp/auth.json auth
~ssh
config load data/work.json work
config load data/flow.json flow
# 服务配置
~nfs
source etc/common.shy
~ssh
remote auto
~nfs
source local.shy
# 应用配置
~code
config load tmp/code.json login
config load tmp/dream.json dream
config load tmp/zsh.json zsh
config load tmp/vim.json vim
~wiki
config load tmp/story.json story
~chat
config load tmp/share.json share
# 终端配置
~cli
~wiki
~chat
~code

View File

@ -1,11 +0,0 @@
#!/bin/sh
if [ -f ~/.ish/plug.sh ]; then
source ~/.ish/plug.sh
require github.com/shylinux/shell help.sh
require github.com/shylinux/shell base/base.sh
require github.com/shylinux/shell core/core.sh
require github.com/shylinux/shell misc/misc.sh
fi

View File

@ -1,19 +0,0 @@
#!/bin/sh
if [ -f ~/.ish/plug.sh ] && source ~/.ish/plug.sh; then
require conf.sh
ish_ctx_cli_prompt
fi
export ZSH=$HOME/.oh-my-zsh
# ZSH_THEME="robbyrussell"
plugins=(tmux git)
source $ZSH/oh-my-zsh.sh
export EDITOR=vim
bindkey "^N" down-line-or-beginning-search
bindkey "^P" up-line-or-beginning-search

View File

@ -14,15 +14,8 @@
role black tech aaa.role role black tech aaa.role
~web ~web
config share meta.host shylinux.com
config share meta.domain https://shylinux.com config share meta.domain https://shylinux.com
spide create mirror.centos.org http://mirror.centos.org
spide create mirrorlist.centos.org http://mirrorlist.centos.org
spide create mirrors.aliyuncs.com http://mirrors.aliyuncs.com
spide create mirrors.cloud.aliyuncs.com http://mirrors.cloud.aliyuncs.com
~web.code.input ~web.code.input
wubi import usr/wubi-dict/person wubi import usr/wubi-dict/person
@ -32,5 +25,4 @@
config footer legal.1 "京ICP备15046864号-1" config footer legal.1 "京ICP备15046864号-1"
~ssh ~ssh
service listen
source local.shy source local.shy

View File

@ -15,8 +15,8 @@ label "理论" `
chapter "项目" chapter "项目"
label "项目" ` label "项目" `
volcanos icebergs intshell intshell icebergs volcanos
learning toolkits contexts contexts toolkits learning
` stroke red fill black ` stroke red fill black
section "框架" section "框架"

View File

@ -1,27 +0,0 @@
title "https://taskhub.com.cn"
refer `
源码 https://github.com/shylinux/contexts
后台 https://shylinux.com
`
spark `将人、事、物高效快速的组织在一起,创建高度可复用的模板、流程、制度。`
premenu
chapter "搭建服务"
web.code.install contexts miss
chapter "创建群组"
chapter "添加用户"
chapter "添加设备"
field "空间站" web.space
spark
web.code.install contexts base
chapter "添加文档"
chapter "添加任务"