ShellCrash/scripts/clashservice

37 lines
966 B
Plaintext
Raw Normal View History

2020-08-03 15:16:33 +08:00
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
USE_PROCD=1
START=92
2020-08-03 15:16:33 +08:00
start_service() {
#开机加载环境变量保证找到文件路径
source /etc/profile > /dev/null 2>&1
#加载修饰脚本
source $clashdir/start.sh
#读取配置文件
2020-08-03 15:16:33 +08:00
getconfig
#使用内置规则强行覆盖config配置文件
[ "$modify_yaml" != "已开启" ] && modify_yaml
2020-08-03 15:16:33 +08:00
#创建clash后台进程
procd_open_instance
procd_set_param respawn
procd_set_param stderr 1
procd_set_param stdout 1
procd_set_param command $clashdir/clash -d $clashdir
2020-08-03 15:16:33 +08:00
procd_close_instance
#修改iptables规则使流量进入clash
stop_iptables
[ "$redir_mod" != "纯净模式" ] && start_dns
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
#标记启动时间
mark_time
#标记启动方式
sed -i /start_old=*/d $ccfg
sed -i "1i\start_old=未开启" $ccfg
2020-08-03 15:16:33 +08:00
}
stop_service() {
source $clashdir/start.sh
stop_iptables
2020-08-03 15:16:33 +08:00
}