mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04: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
|
#! /bin/bash
|
||||||
|
|
||||||
# ctx_log_debug=false
|
# 日志配置
|
||||||
# ctx_log_disable=false
|
export ctx_log=${ctx_log:="var/log"}
|
||||||
# ctx_gdb_enable=false
|
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"}
|
export ctx_app=${ctx_app:="bench"}
|
||||||
ctx_bin=${ctx_bin:=`which ${ctx_app}`} && [ -f bin/${ctx_app} ] && ctx_bin=$(pwd)/bin/${ctx_app}
|
export ctx_bin=${ctx_bin:=$(pwd)/bin/${ctx_app}}; [ -e $ctx_bin ] || export ctx_bin=`which ${ctx_app}`
|
||||||
# ctx_cas=
|
export ctx_root=${ctx_root:=/usr/local/context}
|
||||||
# ctx_ups=
|
export ctx_home=${ctx_home:=~/context}
|
||||||
# ctx_box=
|
|
||||||
ctx_dev=${ctx_dev:="https://shylinux.com"}
|
# 网络配置
|
||||||
ctx_root=${ctx_root:=/usr/local/context}
|
export ctx_cas=${ctx_cas:=""}
|
||||||
ctx_home=${ctx_home:=~/context}
|
export ctx_ups=${ctx_ups:=""}
|
||||||
# ctx_type=
|
export ctx_box=${ctx_box:=""}
|
||||||
# node_cert=
|
export ctx_dev=${ctx_dev:="https://shylinux.com"}
|
||||||
# node_key=
|
|
||||||
# web_port=
|
# 服务配置
|
||||||
# ssh_port=
|
export ctx_type=${ctx_type:="node"}
|
||||||
# HOSTNAME=
|
export ssh_port=${ssh_port:=":9090"}
|
||||||
# USER=
|
export web_port=${web_port:=":9095"}
|
||||||
# PWD=
|
|
||||||
export ctx_log ctx_app ctx_bin ctx_box ctx_cas ctx_dev
|
# 用户配置
|
||||||
export ctx_root ctx_home web_port ssh_port
|
export node_cert=${node_cert:=""}
|
||||||
|
export node_key=${node_key:=""}
|
||||||
|
export HOSTNAME=${HOSTNAME:=""}
|
||||||
|
export USER=${USER:=""}
|
||||||
|
export PWD=${PWD:=""}
|
||||||
|
|
||||||
log() {
|
|
||||||
echo -e $*
|
|
||||||
}
|
|
||||||
install() {
|
install() {
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then mkdir $1; cd $1; shift; fi
|
||||||
mkdir $1; cd $1
|
|
||||||
fi
|
|
||||||
|
|
||||||
md5=md5sum
|
md5=md5sum
|
||||||
case `uname -s` in
|
case `uname -s` in
|
||||||
"Darwin") GOOS=darwin GOARCH=amd64 md5=md5;;
|
"Darwin") GOOS=darwin md5=md5;;
|
||||||
*) GOOS=linux GOARCH=386;;
|
"Linux") GOOS=linux;;
|
||||||
|
*) GOOS=windows;;
|
||||||
esac
|
esac
|
||||||
case `uname -m` in
|
case `uname -m` in
|
||||||
"x86_64") GOARCH=amd64;;
|
"x86_64") GOARCH=amd64;;
|
||||||
"armv7l") GOARCH=arm;;
|
"armv7l") GOARCH=arm;;
|
||||||
|
*) GOARCH=386;;
|
||||||
esac
|
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} \
|
target=install && [ -n "$1" ] && target=$1
|
||||||
&& ${md5} ${ctx_app} && ./${ctx_app} upgrade ${target} && ./${ctx_app} upgrade portal \
|
${md5} ${ctx_app} && ./${ctx_app} upgrade ${target} || return
|
||||||
&& mv ${ctx_app} bin/${ctx_app}
|
|
||||||
}
|
mv ${ctx_app} bin/${ctx_app} && bin/boot.sh
|
||||||
hup() {
|
|
||||||
echo "term hup"
|
|
||||||
}
|
}
|
||||||
main() {
|
main() {
|
||||||
trap HUP hup
|
trap HUP hup
|
||||||
@ -63,17 +64,28 @@ action() {
|
|||||||
pid=$(cat var/run/bench.pid)
|
pid=$(cat var/run/bench.pid)
|
||||||
log "kill" $1 $pid && kill -$1 ${pid}
|
log "kill" $1 $pid && kill -$1 ${pid}
|
||||||
}
|
}
|
||||||
|
hup() { echo "term hup"; }
|
||||||
|
log() { echo -e $*; }
|
||||||
|
|
||||||
|
log "bin:$ctx_bin"
|
||||||
dir=./ && [ -d "$1" ] && dir=$1 && shift
|
|
||||||
[ -d "${dir}" ] && cd ${dir}
|
|
||||||
log "ups:$ctx_ups"
|
|
||||||
log "box:$ctx_box"
|
log "box:$ctx_box"
|
||||||
log "dev:$ctx_dev"
|
log "dev:$ctx_dev"
|
||||||
log "bin:$ctx_bin"
|
log "ups:$ctx_ups"
|
||||||
log "dir:$dir"
|
|
||||||
|
|
||||||
case $1 in
|
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 "$@";;
|
install) shift && install "$@";;
|
||||||
start) shift && main "$@";;
|
start) shift && main "$@";;
|
||||||
"") main "$@";;
|
"") main "$@";;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
export ctx_ups=-
|
export ctx_ups=-
|
||||||
|
export ctx_box=-
|
||||||
export ctx_dev=-
|
export ctx_dev=-
|
||||||
export ctx_type=work
|
export ctx_type=work
|
||||||
|
|
||||||
[ -f bin/boot.sh ] && source bin/boot.sh || source boot.sh
|
[ -f bin/boot.sh ] && source bin/boot.sh || source boot.sh
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
},
|
},
|
||||||
}, Help: "版本发布"},
|
}, Help: "版本发布"},
|
||||||
"upgrade": &ctx.Config{Name: "upgrade", Value: map[string]interface{}{
|
"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"},
|
"system": []interface{}{"boot.sh", "zone.sh", "user.sh", "node.sh", "init.shy", "common.shy", "exit.shy"},
|
||||||
"portal": []interface{}{"template.tar.gz", "librarys.tar.gz"},
|
"portal": []interface{}{"template.tar.gz", "librarys.tar.gz"},
|
||||||
"script": []interface{}{"test.php"},
|
"script": []interface{}{"test.php"},
|
||||||
@ -945,6 +946,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case "install":
|
||||||
|
m.Cmd("cli.upgrade", "system")
|
||||||
|
m.Cmd("cli.upgrade", "portal")
|
||||||
|
|
||||||
case "project":
|
case "project":
|
||||||
m.Cmd("cli.project", "init")
|
m.Cmd("cli.project", "init")
|
||||||
m.Cmd("cli.compile", "all")
|
m.Cmd("cli.compile", "all")
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
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",
|
"trash": "var/tmp/trash",
|
||||||
}, Help: "目录管理"},
|
}, Help: "目录管理"},
|
||||||
"pwd": &ctx.Config{Name: "pwd", Value: []interface{}{
|
"pwd": &ctx.Config{Name: "pwd", Value: []interface{}{
|
||||||
"var", "usr", "usr/local", "bin", "etc", "",
|
"", "usr/local", "usr", "var", "bin", "etc", "src", "src/plugin",
|
||||||
}, Help: "当前目录"},
|
}, Help: "当前目录"},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
@ -629,7 +629,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
|
|
||||||
skip, find := false, false
|
skip, find := false, false
|
||||||
m.Confm("pwd", func(index int, value string) bool {
|
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, e := os.Stat(p); e == nil {
|
||||||
if s.IsDir() {
|
if s.IsDir() {
|
||||||
rg, _ := regexp.Compile(m.Option("dir_reg"))
|
rg, _ := regexp.Compile(m.Option("dir_reg"))
|
||||||
|
@ -20,7 +20,29 @@ context是以分布式的方式,进行程序的开发。
|
|||||||
$ curl https://shylinux.com/publish/boot.sh | bash -s install 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目录下,就是各种执行文件
|
在bin目录下,就是各种执行文件
|
||||||
|
Loading…
x
Reference in New Issue
Block a user