From d31be53ddfea68fc20b256ba04926f2c507f0dd8 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 2 Dec 2020 16:10:09 +0800 Subject: [PATCH] opt contexts --- Makefile | 1 + README.md | 8 -- bin/boot.sh | 106 ------------------------- bin/node.sh | 5 -- bin/template.sh | 189 -------------------------------------------- bin/user.sh | 6 -- bin/zone.sh | 9 --- etc/conf/Makefile | 46 ----------- etc/conf/bashrc | 13 --- etc/conf/common.shy | 6 -- etc/conf/exit.shy | 21 ----- etc/conf/git.conf | 24 ------ etc/conf/init.shy | 34 -------- etc/conf/ishrc | 11 --- etc/conf/zshrc | 19 ----- etc/init.shy | 8 -- src/main.shy | 4 +- src/task.shy | 27 ------- 18 files changed, 3 insertions(+), 534 deletions(-) delete mode 100755 bin/boot.sh delete mode 100755 bin/node.sh delete mode 100755 bin/template.sh delete mode 100755 bin/user.sh delete mode 100755 bin/zone.sh delete mode 100644 etc/conf/Makefile delete mode 100644 etc/conf/bashrc delete mode 100644 etc/conf/common.shy delete mode 100644 etc/conf/exit.shy delete mode 100644 etc/conf/git.conf delete mode 100644 etc/conf/init.shy delete mode 100644 etc/conf/ishrc delete mode 100644 etc/conf/zshrc delete mode 100644 src/task.shy diff --git a/Makefile b/Makefile index 3ffdd921..b5c03035 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ export CGO_ENABLED=0 all: @echo && date go build -v -o bin/ice.bin src/main.go && chmod u+x bin/ice.bin && ./bin/ice.sh restart + relay: src/relay.go @echo && date go build -v -o usr/publish/$@ src/$@.go && chmod u+x usr/publish/$@ diff --git a/README.md b/README.md index 35a10b31..4e91945b 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,10 @@ ice> ``` open http://localhost:9020 -### install by docker -``` -$ docker run -p 9020:9020 -it shylinux/contexts -ice> -``` -open http://localhost:9020 - ### install by source ``` $ git clone https://github.com/shylinux/contexts $ cd contexts && source etc/miss.sh -$ make $ ish_miss_serve ice> ``` diff --git a/bin/boot.sh b/bin/boot.sh deleted file mode 100755 index 6c377052..00000000 --- a/bin/boot.sh +++ /dev/null @@ -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 diff --git a/bin/node.sh b/bin/node.sh deleted file mode 100755 index a03c06d9..00000000 --- a/bin/node.sh +++ /dev/null @@ -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 diff --git a/bin/template.sh b/bin/template.sh deleted file mode 100755 index be2557e7..00000000 --- a/bin/template.sh +++ /dev/null @@ -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} <> ${shy} <> ${main_js} <> Makefile <> ${init_shy} <> ${local_shy} <> "${exit_shy}" <> ${ice_sh} <\$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" <> "$1/$1.shy" <> "$1/$1.go" <