From b9a9ef978e22fd44b4df70aaaaa11749b9bc73b8 Mon Sep 17 00:00:00 2001 From: QL Date: Fri, 30 Jul 2021 15:34:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=89ql=20extra.sh=202021-07-30=2023:34:?= =?UTF-8?q?42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tasks/qlrepo/extra.sh | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Tasks/qlrepo/extra.sh b/Tasks/qlrepo/extra.sh index a2665dd..253bf96 100644 --- a/Tasks/qlrepo/extra.sh +++ b/Tasks/qlrepo/extra.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -## Mod: Build20210730V1 +## Mod: Build20210731V1 ## 添加你需要重启自动执行的任意命令,比如 ql repo ## 安装node依赖使用 pnpm install -g xxx xxx(Build 20210728-002 及以上版本的 code.sh,可忽略) ## 安装python依赖使用 pip3 install xxx(Build 20210728-002 及以上版本的 code.sh,可忽略) @@ -15,7 +15,7 @@ ### (2)若需要在此处使用,请在设置区设置 ## 3. Ninja ### (1)默认不启动和更新 -### (2)若需要启动和更新,则令 Ninja=up +### (2)若需要启动和更新,则令 Ninja=up。此情况下未运行成功将强制重装 #------ 设置区 ------# @@ -120,8 +120,31 @@ done # 🍪Ninja -if [ "${Ninja}" = "up" ]; then - cd /ql/ninja/backend && git checkout . && git pull && pnpm install && pm2 start && cp sendNotify.js /ql/scripts/sendNotify.js & +update_Ninja_normal(){ + [ ! -d /ql/ninja/backend ] && mkdir -p && git checkout . && git pull && pnpm install && pm2 start && cp sendNotify.js /ql/scripts/sendNotify.js & +} + +reinstall_Ninja_force(){ + ps -ef|grep ninja|grep -v grep + if [ $? -ne 0 ] + cd /ql + ps -ef|grep ninja|grep -v grep|awk '{print $1}'|xargs kill -9 && rm -rf /ql/ninja && rm -rf /ql/ninja + git clone https://github.com/MoonBegonia/ninja.git /ql/ninja ## 拉取仓库 + cd /ql/ninja/backend + pnpm install ## 安装局部依赖 + cp .env.example .env ## 复制环境变量配置文件 + cp sendNotify.js /ql/scripts/sendNotify.js ## 复制通知脚本到青龙容器 + pm2 start + fi +} + +check_Ninja_all(){ + update_Ninja_normal + reinstall_Ninja_force +} + +if [ "Ninja" = "up" ]; then + check_Ninja_all & fi @@ -194,4 +217,4 @@ install_dependencies_all(){ if [ "${Install}" = 'yes' ]; then install_dependencies_all & -fi +fi \ No newline at end of file