scripts\install_systemd.sh shutdown.sh start.sh

This commit is contained in:
wnlen
2026-01-15 13:49:23 +08:00
parent 0e1bf1d230
commit f8b6c8cea6
3 changed files with 39 additions and 22 deletions

View File

@ -7,12 +7,14 @@ Temp_Dir="$Server_Dir/temp"
Conf_Dir="$Server_Dir/conf"
PID_FILE="$Temp_Dir/clash.pid"
mkdir -p "$Temp_Dir"
# 1) 优先按 PID_FILE 停
if [ -f "$PID_FILE" ]; then
PID="$(cat "$PID_FILE" 2>/dev/null || true)"
if [ -n "${PID:-}" ] && kill -0 "$PID" 2>/dev/null; then
kill "$PID" 2>/dev/null || true
for _ in {1..5}; do
for _ in {1..8}; do
sleep 1
if ! kill -0 "$PID" 2>/dev/null; then
break
@ -29,7 +31,7 @@ else
PIDS="$(pgrep -f " -d ${Conf_Dir}(\s|$)" || true)"
if [ -n "${PIDS:-}" ]; then
kill $PIDS 2>/dev/null || true
for _ in {1..5}; do
for _ in {1..8}; do
sleep 1
if ! pgrep -f " -d ${Conf_Dir}(\s|$)" >/dev/null 2>&1; then
break
@ -57,4 +59,4 @@ if [ "$Env_File" != "off" ] && [ "$Env_File" != "disabled" ]; then
fi
fi
echo -e "\n服务关闭成功。若当前终端已开启代理请执行proxy_off\n"
echo -e "\n服务关闭成功。若当前终端已开启代理请执行proxy_off\n"