ShellCrash/scripts/shellcrash.procd
juewuy eb025899cd v1.9.1alpha3
~增加主旁转发模式(未妥善测试)
~将DNS进阶设置移动到2-2dns模式设置列表内
~将ipv6进阶设置移动到2-1运行模式设置内
2024-03-09 16:48:29 +08:00

40 lines
1.1 KiB
Bash

#!/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}')
source ${CRASHDIR}/configs/command.env #加载启动命令和启动目录
start_service() {
if [ -n "$(cat $CRASHDIR/configs/ShellCrash.cfg | grep 'firewall_area=5')" ];then
$CRASHDIR/start.sh start_firewall #主旁转发
else
#本机代理用户
[ -n "$(grep 'shellcrash:x:0:7890' /etc/passwd)" ] && USER=shellcrash || USER=root
#检测必须文件
$CRASHDIR/start.sh bfstart
if [ "$?" = "0" ];then
#使用procd创建clash后台进程
procd_open_instance
procd_set_param user $USER
procd_set_param respawn
procd_set_param command $COMMAND
procd_set_param stderr 0
procd_set_param stdout 0
procd_close_instance
#启动结束执行
$CRASHDIR/start.sh afstart &
fi
fi
}
stop_service(){
procd_close_instance
$CRASHDIR/start.sh stop_firewall
$CRASHDIR/start.sh unset_proxy
}