2020-08-03 15:16:33 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
|
2020-08-17 12:44:55 +08:00
|
|
|
START=92
|
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-09-21 16:21:26 +08:00
|
|
|
DIR=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
2020-09-20 17:57:21 +08:00
|
|
|
|
2020-08-03 15:16:33 +08:00
|
|
|
start_service() {
|
2020-09-20 17:57:21 +08:00
|
|
|
#使用procd创建clash后台进程
|
2020-08-03 15:16:33 +08:00
|
|
|
procd_open_instance
|
|
|
|
procd_set_param respawn
|
|
|
|
procd_set_param stderr 1
|
|
|
|
procd_set_param stdout 1
|
2020-09-21 16:21:26 +08:00
|
|
|
procd_set_param command $DIR/clash -d $DIR
|
2020-08-03 15:16:33 +08:00
|
|
|
procd_close_instance
|
2020-09-18 21:09:06 +08:00
|
|
|
#其他设置
|
2020-09-21 16:21:26 +08:00
|
|
|
$DIR/start.sh afstart
|
2020-08-03 15:16:33 +08:00
|
|
|
}
|
2020-09-20 17:57:21 +08:00
|
|
|
|
|
|
|
start() {
|
|
|
|
if [ -z "$(pidof procd)" ];then
|
|
|
|
#创建后台进程
|
2020-09-21 16:21:26 +08:00
|
|
|
service_start $DIR/clash -d $DIR
|
|
|
|
#设置守护进程
|
|
|
|
$DIR/start.sh deamon
|
2020-09-20 17:57:21 +08:00
|
|
|
#其他设置
|
2020-09-21 16:21:26 +08:00
|
|
|
$DIR/start.sh afstart
|
2020-09-20 17:57:21 +08:00
|
|
|
else
|
|
|
|
start_service
|
|
|
|
fi
|
|
|
|
}
|