Harden startup defaults and process shutdown

This commit is contained in:
wnlen
2026-01-13 22:52:55 +08:00
parent 4861cc40e5
commit e9afaa0669
4 changed files with 64 additions and 35 deletions

View File

@ -45,12 +45,21 @@ Log_Dir="$Server_Dir/logs"
Text1="服务关闭成功!"
Text2="服务关闭失败!"
# 查询并关闭程序进程
PID_NUM=`ps -ef | grep [c]lash-linux-a | wc -l`
PID=`ps -ef | grep [c]lash-linux-a | awk '{print $2}'`
if [ $PID_NUM -ne 0 ]; then
kill -9 $PID
ReturnStatus=$?
# ps -ef | grep [c]lash-linux-a | awk '{print $2}' | xargs kill -9
PIDS=$(pgrep -f "clash-linux-")
if [ -n "$PIDS" ]; then
kill $PIDS
ReturnStatus=$?
for i in {1..5}; do
sleep 1
if ! pgrep -f "clash-linux-" >/dev/null; then
break
fi
done
if pgrep -f "clash-linux-" >/dev/null; then
kill -9 $PIDS
fi
else
ReturnStatus=0
fi
if_success $Text1 $Text2 $ReturnStatus
@ -87,4 +96,3 @@ else
echo -e "\033[31m\n[ERROR] Unsupported CPU Architecture\033[0m"
exit 1
fi