2020-08-03 15:16:33 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
|
2021-07-11 01:03:43 +08:00
|
|
|
START=99
|
2020-08-03 15:16:33 +08:00
|
|
|
|
2020-09-20 17:57:21 +08:00
|
|
|
SERVICE_DAEMONIZE=1
|
|
|
|
SERVICE_WRITE_PID=1
|
|
|
|
USE_PROCD=1
|
2020-10-30 16:21:09 +08:00
|
|
|
#获取目录
|
|
|
|
DIR=$(cat /etc/profile | grep clashdir | awk -F "\"" '{print $2}')
|
2020-11-15 13:01:29 +08:00
|
|
|
[ -z "$DIR" ] && DIR=$(cat ~/.bashrc | grep clashdir | awk -F "\"" '{print $2}')
|
2020-10-30 16:21:09 +08:00
|
|
|
BINDIR=$(cat $DIR/mark | grep bindir | awk -F "=" '{print $2}')
|
|
|
|
[ -z "$BINDIR" ] && BINDIR=$DIR
|
2020-09-20 17:57:21 +08:00
|
|
|
|
2020-08-03 15:16:33 +08:00
|
|
|
start_service() {
|
2020-10-30 16:21:09 +08:00
|
|
|
#检测必须文件
|
|
|
|
$DIR/start.sh bfstart
|
2022-01-21 17:14:31 +08:00
|
|
|
if [ "$?" = "0" ];then
|
|
|
|
#使用procd创建clash后台进程
|
|
|
|
procd_open_instance
|
|
|
|
procd_set_param respawn
|
2022-01-27 13:12:28 +08:00
|
|
|
procd_set_param stderr 0
|
|
|
|
procd_set_param stdout 0
|
2022-01-21 17:14:31 +08:00
|
|
|
procd_set_param command $BINDIR/clash -d $BINDIR
|
|
|
|
procd_close_instance
|
|
|
|
#其他设置
|
|
|
|
$DIR/start.sh afstart
|
|
|
|
fi
|
2020-08-03 15:16:33 +08:00
|
|
|
}
|
2020-09-20 17:57:21 +08:00
|
|
|
|
|
|
|
start() {
|
|
|
|
if [ -z "$(pidof procd)" ];then
|
2020-10-30 16:21:09 +08:00
|
|
|
#检测必须文件
|
|
|
|
$DIR/start.sh bfstart
|
2022-01-21 17:14:31 +08:00
|
|
|
if [ "$?" = "0" ];then
|
|
|
|
#创建后台进程
|
|
|
|
service_start $BINDIR/clash -d $BINDIR
|
|
|
|
#其他设置
|
|
|
|
$DIR/start.sh afstart
|
|
|
|
#设置守护进程
|
|
|
|
$DIR/start.sh deamon
|
|
|
|
fi
|
2020-09-20 17:57:21 +08:00
|
|
|
else
|
|
|
|
start_service
|
|
|
|
fi
|
2022-01-21 17:14:31 +08:00
|
|
|
}
|