Skip to content

Commit

Permalink
🌱check_Ninja_normal()
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreomeow committed Aug 25, 2021
1 parent 809b555 commit 2771256
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Scripts/sh/1custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ set_default_extra() {
sed -i "s/CollectedRepo=(4)/CollectedRepo=(${CollectedRepo})/g" $extra_shell_path
sed -i "s/OtherRepo=()/OtherRepo=(${OtherRepo})/g" $extra_shell_path
echo -e "Ninja\n###(1)默认启动并自动更新\n###(2)!!!未修改容器映射的请勿运行,否则会出现青龙打不开或者设备死机等不良后果,映射参考 https://github.com/MoonBegonia/ninja#%E5%AE%B9%E5%99%A8%E5%86%85"
read -p "Ninja="up" ## up为运行,down为不运行,请输入您的设置(默认运行) up/down:" Ninja
sed -i "s/Ninja=\"up\"/Ninja=\"${Ninja}\"/" $extra_shell_path
read -p "Ninja="on" ##up为更新,on为启动,down为不运行,请输入您的设置(默认运行) up/on/down:" Ninja
sed -i "s/Ninja=\"on\"/Ninja=\"${Ninja}\"/" $extra_shell_path
}
# 将 ql extra 添加到定时任务
add_ql_extra() {
Expand Down
4 changes: 2 additions & 2 deletions Scripts/sh/1customCDN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ set_default_extra() {
sed -i "s/CollectedRepo=(4)/CollectedRepo=(${CollectedRepo})/g" $extra_shell_path
sed -i "s/OtherRepo=()/OtherRepo=(${OtherRepo})/g" $extra_shell_path
echo -e "Ninja\n###(1)默认启动并自动更新\n###(2)!!!未修改容器映射的请勿运行,否则会出现青龙打不开或者设备死机等不良后果,映射参考 https://github.com/MoonBegonia/ninja#%E5%AE%B9%E5%99%A8%E5%86%85"
read -p "Ninja="up" ## up为运行,down为不运行,请输入您的设置(默认运行) up/down:" Ninja
sed -i "s/Ninja=\"up\"/Ninja=\"${Ninja}\"/" $extra_shell_path
read -p "Ninja="on" ##up为更新,on为启动,down为不运行,请输入您的设置(默认运行) up/on/down:" Ninja
sed -i "s/Ninja=\"on\"/Ninja=\"${Ninja}\"/" $extra_shell_path
}
# 将 ql extra 添加到定时任务
add_ql_extra() {
Expand Down
2 changes: 1 addition & 1 deletion Scripts/sh/scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ while ((i<=0)); do
fi
else
i=1
echo $NOWTIME" 扫描结束!NINJA还在"
echo $NOWTIME" 扫描结束!NINJA 还在"
fi
done

Expand Down
33 changes: 31 additions & 2 deletions Tasks/qlrepo/extra.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
## Mod: Build20210825V1
## Mod: Build20210825V2
## 添加你需要重启自动执行的任意命令,比如 ql repo
## 安装node依赖使用 pnpm install -g xxx xxx(Build 20210728-002 及以上版本的 code.sh,可忽略)
## 安装python依赖使用 pip3 install xxx(Build 20210728-002 及以上版本的 code.sh,可忽略)
Expand All @@ -26,7 +26,7 @@ OtherRepo=() ##示例:OtherRepo=(1 3)
dependencies="no" ##yes为安装,no为不安装
package_name="canvas png-js date-fns axios crypto-js ts-md5 tslib @types/node dotenv typescript fs require tslib"
## 3. Ninja 是否需要启动和更新设置
Ninja="up" ##up为运行,down为不运行
Ninja="on" ##up为更新,on为启动,down为不运行


#------ 编号区 ------#
Expand Down Expand Up @@ -131,8 +131,37 @@ update_Ninja_normal(){
cp sendNotify.js /ql/scripts/sendNotify.js
}

check_Ninja_normal(){
NOWTIME=$(date +%Y-%m-%d-%H-%M-%S)
i=0
while ((i<=0)); do
echo "扫描 Ninja 是否在线"
ps -fe|grep ninja|grep -v grep
if [ $? -ne 0 ]; then
i=0
echo $NOWTIME" 扫描结束!Ninja 掉线了不用担心马上重启!"
cd /ql
ps -ef|grep ninja|grep -v grep|awk '{print $1}'|xargs kill -9
cd /ql/ninja/backend
pnpm install
pm2 start
ps -fe|grep Daemon |grep -v grep
if [ $? -ne 1 ]; then
i=1
echo $NOWTIME" Ninja 重启完成!"
curl "https://api.telegram.org/bot$TG_BOT_TOKEN/sendMessage?chat_id=$TG_USER_ID&text=Ninja 已重启完成"
fi
else
i=1
echo $NOWTIME" 扫描结束!Ninja 还在!"
fi
done
}

if [ "$Ninja" = "up" ]; then
update_Ninja_normal &
elif [ "$Ninja" = "on" ]; then
check_Ninja_normal
fi


Expand Down

0 comments on commit 2771256

Please sign in to comment.