mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 03:32:34 +08:00
4ec7a5dda1
~修复小米设备开启自启失败的问题 ~修复本机代理nftables增强模式部分情况下无法代理docker流量的问题 ~修复本机代理iptables提示重复添加的问题
46 lines
1014 B
Bash
46 lines
1014 B
Bash
#!/bin/sh /etc/rc.common
|
|
|
|
START=99
|
|
|
|
SERVICE_DAEMONIZE=1
|
|
SERVICE_WRITE_PID=1
|
|
USE_PROCD=1
|
|
#获取目录
|
|
DIR=$(cat /etc/profile | grep clashdir | awk -F "\"" '{print $2}')
|
|
[ -z "$DIR" ] && DIR=$(cat ~/.bashrc | grep clashdir | awk -F "\"" '{print $2}')
|
|
BINDIR=$(cat $DIR/configs/ShellClash.cfg | grep bindir | awk -F "=" '{print $2}')
|
|
[ -z "$BINDIR" ] && BINDIR=$DIR
|
|
|
|
start_service() {
|
|
#检测必须文件
|
|
$DIR/start.sh bfstart
|
|
if [ "$?" = "0" ];then
|
|
#使用procd创建clash后台进程
|
|
procd_open_instance
|
|
procd_set_param respawn
|
|
procd_set_param stderr 0
|
|
procd_set_param stdout 0
|
|
procd_set_param command $BINDIR/clash -d $BINDIR
|
|
procd_close_instance
|
|
#其他设置
|
|
$DIR/start.sh afstart
|
|
fi
|
|
}
|
|
|
|
start() {
|
|
if [ -z "$(pidof procd)" ];then
|
|
#检测必须文件
|
|
$DIR/start.sh bfstart
|
|
if [ "$?" = "0" ];then
|
|
#创建后台进程
|
|
service_start $BINDIR/clash -d $BINDIR
|
|
#其他设置
|
|
$DIR/start.sh afstart
|
|
#设置守护进程
|
|
$DIR/start.sh daemon
|
|
fi
|
|
else
|
|
start_service
|
|
fi
|
|
}
|