zjcqoo 6 年之前
父节点
当前提交
55dc3ca084
共有 5 个文件被更改,包括 52 次插入17 次删除
  1. 3 1
      .gitignore
  2. 3 0
      api.conf
  3. 29 0
      docs/compile.md
  4. 15 14
      i.sh
  5. 2 2
      upload.sh

+ 3 - 1
.gitignore

@@ -1 +1,3 @@
-._*
+._*
+upload.sh
+release.sh

+ 3 - 0
api.conf

@@ -1,3 +1,6 @@
+if ($uri = '/ver') {
+  return              200   '0.0.4';
+}
 if ($_origin_id = '') {
   return              403   'ERROR: origin `$http_origin` is not allowed';
 }

+ 29 - 0
docs/compile.md

@@ -0,0 +1,29 @@
+源码编译安装
+
+默认的安装方式,是直接下载编译后的 nginx 程序。目前只提供 Linux x64 系统的文件,其他系统暂不支持,需要从源码编译。
+
+此外,对于没有 root 权限的系统,也需通过源码编译,从而改变 nginx 的安装位置。(nginx 程序路径是在编译时通过 `--prefix` 参数指定的,改变程序位置会导致某些链接库无法加载。如果有好的解决方案多指教~)
+
+
+# 依赖
+
+需要安装 make、gcc 等,参考 nginx 的编译。
+
+无需安装 pcre、zlib、openssl 开发库,安装脚本会自动下载源码。
+
+
+# 脚本
+
+```bash
+curl -O https://raw.githubusercontent.com/EtherDream/jsproxy/master/i.sh
+bash i.sh compile
+```
+
+nginx 最终安装在 `$HOME/openresty` 目录下。代理服务安装在当前 `server` 目录下。
+
+
+# 支持
+
+目前测试过的系统:
+
+* OSX

+ 15 - 14
i.sh

@@ -2,7 +2,7 @@
 
 CDN=https://cdn.jsdelivr.net/gh/etherdream/jsproxy-bin@master
 
-JSPROXY_VER=0.0.4
+JSPROXY_VER=0.0.6
 PCRE_VER=8.43
 ZLIB_VER=1.2.11
 OPENSSL_VER=1.1.1b
@@ -35,15 +35,6 @@ err() {
   output $COLOR_RED $1
 }
 
-is_running() {
-  RET=$(curl -s http://127.0.0.1:8080/)
-
-  if [[ "$RET" != *"origin"* ]]; then
-    return 0
-  fi
-  return 1
-}
-
 check_nginx() {
   NGX_EXE="$NGX_DIR/nginx/sbin/nginx"
   NGX_VER=$($NGX_EXE -v 2>&1)
@@ -60,8 +51,8 @@ install_jsproxy() {
   log "下载代理服务 ..."
   curl -s -O $CDN/server-$JSPROXY_VER.tar.gz
 
-  if is_running ; then
-    warn "停止当前服务 ..."
+  if [ -x ./server/run.sh ]; then
+    warn "尝试停止当前服务 ..."
     ./server/run.sh quit
   fi
 
@@ -79,9 +70,11 @@ install_jsproxy() {
   ./server/run.sh
 
   log "检测状态 ..."
-  if ! is_running ; then
+  ret=$(curl -s http://127.0.0.1:8080/ver)
+
+  if [[ "$ret" != "$JSPROXY_VER" ]]; then
     err "服务启动异常!错误日志:"
-    tail server/nginx/logs/error.log -n100
+    tail server/nginx/logs/error.log
     exit 1
   fi
 
@@ -145,10 +138,16 @@ install() {
   install_jsproxy
 }
 
+update() {
+  install_jsproxy
+}
+
 pack() {
   log "压缩 openresty ..."
   GZIP=-9
   tar cvzf openresty.tar.gz openresty
+  log "done"
+  ls -la
 }
 
 main() {
@@ -185,6 +184,8 @@ case "$1" in
   exit;;
 "compile") compile
   exit;;
+"update") update
+  exit;;
 "pack") pack
   exit;;
 *) main

+ 2 - 2
upload.sh

@@ -3,9 +3,9 @@
 
 HOST=etherdream.com
 NODE=(
-  node-aliyun-hk
+  node-aliyun-hk-0
+  node-aliyun-hk-1
   node-aliyun-sg
-  node-bwh-los
 )
 for v in ${NODE[@]}; do
   echo "$v upload ..."