mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 11:42:18 +08:00
Merge pull request #378 from RikudouPatrickstar/pr
修复PID判断不精准导致获取运行状态出错的问题
This commit is contained in:
commit
5b53cbc3a9
|
@ -63,7 +63,7 @@ ckstatus(){
|
||||||
auto1="\033[36m允许\033[0mclash开机启动"
|
auto1="\033[36m允许\033[0mclash开机启动"
|
||||||
fi
|
fi
|
||||||
#获取运行状态
|
#获取运行状态
|
||||||
PID=$(pidof clash)
|
PID=$(pidof $clashdir/clash)
|
||||||
if [ -n "$PID" ];then
|
if [ -n "$PID" ];then
|
||||||
run="\033[32m正在运行($redir_mod)\033[0m"
|
run="\033[32m正在运行($redir_mod)\033[0m"
|
||||||
VmRSS=`cat /proc/$PID/status|grep -w VmRSS|awk '{print $2,$3}'`
|
VmRSS=`cat /proc/$PID/status|grep -w VmRSS|awk '{print $2,$3}'`
|
||||||
|
@ -178,7 +178,7 @@ clashstart(){
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
$clashdir/start.sh start
|
$clashdir/start.sh start
|
||||||
sleep 1
|
sleep 1
|
||||||
[ -n "$(pidof clash)" ] && startover
|
[ -n "$(pidof $clashdir/clash)" ] && startover
|
||||||
}
|
}
|
||||||
checkrestart(){
|
checkrestart(){
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
|
@ -1286,7 +1286,7 @@ clashcfg(){
|
||||||
setconfig common_ports $common_ports
|
setconfig common_ports $common_ports
|
||||||
}
|
}
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
if [ -n "$(pidof clash)" ];then
|
if [ -n "$(pidof $clashdir/clash)" ];then
|
||||||
read -p "切换时将停止clash服务,是否继续?(1/0) > " res
|
read -p "切换时将停止clash服务,是否继续?(1/0) > " res
|
||||||
[ "$res" = 1 ] && $clashdir/start.sh stop && set_common_ports
|
[ "$res" = 1 ] && $clashdir/start.sh stop && set_common_ports
|
||||||
else
|
else
|
||||||
|
@ -1486,7 +1486,7 @@ EOF
|
||||||
;;
|
;;
|
||||||
8)
|
8)
|
||||||
source $CFG_PATH
|
source $CFG_PATH
|
||||||
if [ -n "$(pidof clash)" ];then
|
if [ -n "$(pidof $clashdir/clash)" ];then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[33m检测到clash服务正在运行,需要先停止clash服务!\033[0m"
|
echo -e "\033[33m检测到clash服务正在运行,需要先停止clash服务!\033[0m"
|
||||||
read -p "是否停止clash服务?(1/0) > " res
|
read -p "是否停止clash服务?(1/0) > " res
|
||||||
|
|
|
@ -63,7 +63,7 @@ case "$1" in
|
||||||
tunfix) tunfix ;;
|
tunfix) tunfix ;;
|
||||||
init) init ;;
|
init) init ;;
|
||||||
*)
|
*)
|
||||||
if [ -z $(pidof clash) ];then
|
if [ -z $(pidof $clashdir/clash) ];then
|
||||||
init
|
init
|
||||||
else
|
else
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
|
@ -57,7 +57,7 @@ logger(){
|
||||||
[ -z "$3" ] && {
|
[ -z "$3" ] && {
|
||||||
getconfig
|
getconfig
|
||||||
[ -n "$device_name" ] && log_text="$log_text($device_name)"
|
[ -n "$device_name" ] && log_text="$log_text($device_name)"
|
||||||
[ -n "$(pidof clash)" ] && {
|
[ -n "$(pidof $clashdir/clash)" ] && {
|
||||||
[ -n "$authentication" ] && auth="$authentication@"
|
[ -n "$authentication" ] && auth="$authentication@"
|
||||||
export https_proxy="http://${auth}127.0.0.1:$mix_port"
|
export https_proxy="http://${auth}127.0.0.1:$mix_port"
|
||||||
}
|
}
|
||||||
|
@ -1251,7 +1251,7 @@ afstart(){
|
||||||
#加载定时任务
|
#加载定时任务
|
||||||
[ -f $clashdir/cron ] && croncmd $clashdir/cron
|
[ -f $clashdir/cron ] && croncmd $clashdir/cron
|
||||||
#启用面板配置自动保存
|
#启用面板配置自动保存
|
||||||
cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置"
|
cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof $clashdir/clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置"
|
||||||
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
|
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
|
||||||
#推送日志
|
#推送日志
|
||||||
{ sleep 30;logger Clash服务已启动!;} &
|
{ sleep 30;logger Clash服务已启动!;} &
|
||||||
|
@ -1283,7 +1283,7 @@ afstart)
|
||||||
afstart
|
afstart
|
||||||
;;
|
;;
|
||||||
start)
|
start)
|
||||||
[ -n "$(pidof clash)" ] && $0 stop #禁止多实例
|
[ -n "$(pidof $clashdir/clash)" ] && $0 stop #禁止多实例
|
||||||
getconfig
|
getconfig
|
||||||
#检测必须文件并下载
|
#检测必须文件并下载
|
||||||
bfstart
|
bfstart
|
||||||
|
@ -1304,7 +1304,7 @@ start)
|
||||||
stop)
|
stop)
|
||||||
getconfig
|
getconfig
|
||||||
logger Clash服务即将关闭……
|
logger Clash服务即将关闭……
|
||||||
[ -n "$(pidof clash)" ] && [ "$restore" = false ] && web_save #保存面板配置
|
[ -n "$(pidof $clashdir/clash)" ] && [ "$restore" = false ] && web_save #保存面板配置
|
||||||
#删除守护进程&面板配置自动保存
|
#删除守护进程&面板配置自动保存
|
||||||
cronset "clash保守模式守护进程"
|
cronset "clash保守模式守护进程"
|
||||||
cronset "保存节点配置"
|
cronset "保存节点配置"
|
||||||
|
@ -1315,7 +1315,7 @@ stop)
|
||||||
elif [ "$USER" = "root" ];then
|
elif [ "$USER" = "root" ];then
|
||||||
systemctl stop clash.service >/dev/null 2>&1
|
systemctl stop clash.service >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
PID=$(pidof clash) && [ -n "$PID" ] && kill -9 $PID >/dev/null 2>&1
|
PID=$(pidof $clashdir/clash) && [ -n "$PID" ] && kill -9 $PID >/dev/null 2>&1
|
||||||
stop_firewall #清理路由策略
|
stop_firewall #清理路由策略
|
||||||
$0 unset_proxy #禁用本机代理
|
$0 unset_proxy #禁用本机代理
|
||||||
;;
|
;;
|
||||||
|
@ -1367,7 +1367,7 @@ logger)
|
||||||
;;
|
;;
|
||||||
webget)
|
webget)
|
||||||
#设置临时代理
|
#设置临时代理
|
||||||
if [ -n "$(pidof clash)" ];then
|
if [ -n "$(pidof $clashdir/clash)" ];then
|
||||||
getconfig
|
getconfig
|
||||||
[ -n "$authentication" ] && auth="$authentication@"
|
[ -n "$authentication" ] && auth="$authentication@"
|
||||||
export https_proxy="http://${auth}127.0.0.1:$mix_port"
|
export https_proxy="http://${auth}127.0.0.1:$mix_port"
|
||||||
|
@ -1413,7 +1413,7 @@ web_restore)
|
||||||
;;
|
;;
|
||||||
daemon)
|
daemon)
|
||||||
getconfig
|
getconfig
|
||||||
cronset '#clash保守模式守护进程' "*/1 * * * * test -z \"\$(pidof clash)\" && $clashdir/start.sh restart #clash保守模式守护进程"
|
cronset '#clash保守模式守护进程' "*/1 * * * * test -z \"\$(pidof $clashdir/clash)\" && $clashdir/start.sh restart #clash保守模式守护进程"
|
||||||
;;
|
;;
|
||||||
cronset)
|
cronset)
|
||||||
cronset $2 $3
|
cronset $2 $3
|
||||||
|
|
Loading…
Reference in New Issue
Block a user