2024-01-06 22:35:41 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
|
|
|
|
START=99
|
|
|
|
|
|
|
|
SERVICE_DAEMONIZE=1
|
|
|
|
SERVICE_WRITE_PID=1
|
|
|
|
USE_PROCD=1
|
|
|
|
#获取目录
|
|
|
|
CRASHDIR=$(cat /etc/profile | grep CRASHDIR | awk -F "\"" '{print $2}')
|
|
|
|
[ -z "$CRASHDIR" ] && CRASHDIR=$(cat ~/.bashrc | grep CRASHDIR | awk -F "\"" '{print $2}')
|
2024-01-10 22:02:15 +08:00
|
|
|
source ${CRASHDIR}/configs/command.env #加载启动命令和启动目录
|
2024-01-06 22:35:41 +08:00
|
|
|
|
|
|
|
start_service() {
|
2024-01-24 17:46:38 +08:00
|
|
|
#本机代理用户
|
|
|
|
[ -n "$(grep -E 'local_type.*增强模式' ${CRASHDIR}/configs/ShellCrash.cfg)" ] && USER=shellcrash || USER=root
|
2024-02-01 23:14:28 +08:00
|
|
|
#检测必须文件
|
|
|
|
$CRASHDIR/start.sh bfstart
|
2024-01-06 22:35:41 +08:00
|
|
|
if [ "$?" = "0" ];then
|
|
|
|
#使用procd创建clash后台进程
|
|
|
|
procd_open_instance
|
2024-01-24 17:46:38 +08:00
|
|
|
procd_set_param user $USER
|
2024-01-06 22:35:41 +08:00
|
|
|
procd_set_param respawn
|
2024-01-10 22:02:15 +08:00
|
|
|
procd_set_param command $COMMAND
|
2024-01-06 22:35:41 +08:00
|
|
|
procd_set_param stderr 0
|
|
|
|
procd_set_param stdout 0
|
|
|
|
procd_close_instance
|
2024-01-10 22:02:15 +08:00
|
|
|
#启动结束执行
|
2024-02-01 23:14:28 +08:00
|
|
|
$CRASHDIR/start.sh afstart &
|
2024-01-06 22:35:41 +08:00
|
|
|
fi
|
|
|
|
}
|
2024-01-10 22:02:15 +08:00
|
|
|
stop_service(){
|
|
|
|
procd_close_instance
|
|
|
|
$CRASHDIR/start.sh stop_firewall
|
|
|
|
$CRASHDIR/start.sh unset_proxy
|
|
|
|
}
|