mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
opt boot.sh
This commit is contained in:
parent
09d1f96090
commit
1c43fdaab4
98
bin/boot.sh
98
bin/boot.sh
@ -1,55 +1,56 @@
|
||||
#! /bin/bash
|
||||
|
||||
# ctx_log_debug=false
|
||||
# ctx_log_disable=false
|
||||
# ctx_gdb_enable=false
|
||||
# 日志配置
|
||||
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}
|
||||
|
||||
ctx_log=${ctx_log:="var/log"}
|
||||
ctx_app=${ctx_app:="bench"}
|
||||
ctx_bin=${ctx_bin:=`which ${ctx_app}`} && [ -f bin/${ctx_app} ] && ctx_bin=$(pwd)/bin/${ctx_app}
|
||||
# ctx_cas=
|
||||
# ctx_ups=
|
||||
# ctx_box=
|
||||
ctx_dev=${ctx_dev:="https://shylinux.com"}
|
||||
ctx_root=${ctx_root:=/usr/local/context}
|
||||
ctx_home=${ctx_home:=~/context}
|
||||
# ctx_type=
|
||||
# node_cert=
|
||||
# node_key=
|
||||
# web_port=
|
||||
# ssh_port=
|
||||
# HOSTNAME=
|
||||
# USER=
|
||||
# PWD=
|
||||
export ctx_log ctx_app ctx_bin ctx_box ctx_cas ctx_dev
|
||||
export ctx_root ctx_home web_port ssh_port
|
||||
# 目录配置
|
||||
export ctx_app=${ctx_app:="bench"}
|
||||
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:=""}
|
||||
|
||||
log() {
|
||||
echo -e $*
|
||||
}
|
||||
install() {
|
||||
if [ -n "$1" ]; then
|
||||
mkdir $1; cd $1
|
||||
fi
|
||||
if [ -n "$1" ]; then mkdir $1; cd $1; shift; fi
|
||||
|
||||
md5=md5sum
|
||||
case `uname -s` in
|
||||
"Darwin") GOOS=darwin GOARCH=amd64 md5=md5;;
|
||||
*) GOOS=linux GOARCH=386;;
|
||||
"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
|
||||
|
||||
target=system && [ -n "$2" ] && target=$2
|
||||
curl -o ${ctx_app} "$ctx_dev/publish/${ctx_app}?GOOS=$GOOS&GOARCH=$GOARCH" &>/dev/null && chmod a+x ${ctx_app} || return
|
||||
|
||||
wget -O ${ctx_app} "$ctx_dev/publish/${ctx_app}?GOOS=$GOOS&GOARCH=$GOARCH" && chmod a+x ${ctx_app} \
|
||||
&& ${md5} ${ctx_app} && ./${ctx_app} upgrade ${target} && ./${ctx_app} upgrade portal \
|
||||
&& mv ${ctx_app} bin/${ctx_app}
|
||||
}
|
||||
hup() {
|
||||
echo "term hup"
|
||||
target=install && [ -n "$1" ] && target=$1
|
||||
${md5} ${ctx_app} && ./${ctx_app} upgrade ${target} || return
|
||||
|
||||
mv ${ctx_app} bin/${ctx_app} && bin/boot.sh
|
||||
}
|
||||
main() {
|
||||
trap HUP hup
|
||||
@ -63,17 +64,28 @@ action() {
|
||||
pid=$(cat var/run/bench.pid)
|
||||
log "kill" $1 $pid && kill -$1 ${pid}
|
||||
}
|
||||
hup() { echo "term hup"; }
|
||||
log() { echo -e $*; }
|
||||
|
||||
|
||||
dir=./ && [ -d "$1" ] && dir=$1 && shift
|
||||
[ -d "${dir}" ] && cd ${dir}
|
||||
log "ups:$ctx_ups"
|
||||
log "bin:$ctx_bin"
|
||||
log "box:$ctx_box"
|
||||
log "dev:$ctx_dev"
|
||||
log "bin:$ctx_bin"
|
||||
log "dir:$dir"
|
||||
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 "$@";;
|
||||
start) shift && main "$@";;
|
||||
"") main "$@";;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#! /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
|
||||
|
||||
|
||||
|
@ -139,6 +139,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
},
|
||||
}, Help: "版本发布"},
|
||||
"upgrade": &ctx.Config{Name: "upgrade", Value: map[string]interface{}{
|
||||
"install": []interface{}{"system"},
|
||||
"system": []interface{}{"boot.sh", "zone.sh", "user.sh", "node.sh", "init.shy", "common.shy", "exit.shy"},
|
||||
"portal": []interface{}{"template.tar.gz", "librarys.tar.gz"},
|
||||
"script": []interface{}{"test.php"},
|
||||
@ -945,6 +946,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
}
|
||||
|
||||
switch arg[0] {
|
||||
case "install":
|
||||
m.Cmd("cli.upgrade", "system")
|
||||
m.Cmd("cli.upgrade", "portal")
|
||||
|
||||
case "project":
|
||||
m.Cmd("cli.project", "init")
|
||||
m.Cmd("cli.compile", "all")
|
||||
|
@ -4,5 +4,5 @@ var version = struct {
|
||||
host string
|
||||
self int
|
||||
}{
|
||||
"2019-09-12 16:21:30", "centos", 529,
|
||||
"2019-09-12 22:20:19", "centos", 532,
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
"trash": "var/tmp/trash",
|
||||
}, Help: "目录管理"},
|
||||
"pwd": &ctx.Config{Name: "pwd", Value: []interface{}{
|
||||
"var", "usr", "usr/local", "bin", "etc", "",
|
||||
"", "usr/local", "usr", "var", "bin", "etc", "src", "src/plugin",
|
||||
}, Help: "当前目录"},
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
@ -629,7 +629,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
|
||||
skip, find := false, false
|
||||
m.Confm("pwd", func(index int, value string) bool {
|
||||
p := path.Join(value, arg[0])
|
||||
p := kit.Select("./", path.Join(value, arg[0]))
|
||||
if s, e := os.Stat(p); e == nil {
|
||||
if s.IsDir() {
|
||||
rg, _ := regexp.Compile(m.Option("dir_reg"))
|
||||
|
@ -20,7 +20,29 @@ context是以分布式的方式,进行程序的开发。
|
||||
$ curl https://shylinux.com/publish/boot.sh | bash -s install context
|
||||
```
|
||||
|
||||
install后面的参数context,就是指定的下载目录,
|
||||
install后面的参数context,就是指定的下载目录,如不指定,会把相关文件下载到当前目录。
|
||||
|
||||
下载完成后,会自动启动context,
|
||||
windows下的GitBash中,如果自动启动失败,则需要手动启动一下。
|
||||
```
|
||||
$ cd context && bin/boot.sh
|
||||
```
|
||||
|
||||
启动后context,就是一种交互式的shell,可以执行各种内部命令和系统本地命令。
|
||||
如下查看当前目录与当目录下的文件。
|
||||
```
|
||||
0[22:21:19]nfs> pwd
|
||||
/home/homework/context
|
||||
|
||||
1[22:21:20]nfs> dir
|
||||
time size line path
|
||||
2019-09-12 22:21:18 103 5 bin/
|
||||
2019-09-12 22:20:40 72 3 etc/
|
||||
2019-09-12 22:21:18 50 2 usr/
|
||||
2019-09-12 22:20:40 55 3 var/
|
||||
2[22:21:20]nfs>
|
||||
```
|
||||
|
||||
进入下载目录,可以看到的有八个文件。
|
||||
|
||||
在bin目录下,就是各种执行文件
|
||||
|
Loading…
x
Reference in New Issue
Block a user