2020-08-03 15:16:33 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Example script
|
|
|
|
# Copyright (C) 2007 OpenWrt.org
|
|
|
|
|
|
|
|
USE_PROCD=1
|
2020-08-17 12:44:55 +08:00
|
|
|
START=92
|
2020-08-03 15:16:33 +08:00
|
|
|
|
|
|
|
start_service() {
|
2020-08-22 19:05:02 +08:00
|
|
|
#开机加载环境变量保证找到文件路径
|
|
|
|
source /etc/profile > /dev/null 2>&1
|
|
|
|
#加载修饰脚本
|
|
|
|
source $clashdir/start.sh
|
|
|
|
#读取配置文件
|
2020-08-03 15:16:33 +08:00
|
|
|
getconfig
|
2020-08-07 12:25:20 +08:00
|
|
|
#使用内置规则强行覆盖config配置文件
|
2020-08-22 19:05:02 +08:00
|
|
|
[ "$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
|
2020-08-06 18:11:00 +08:00
|
|
|
procd_set_param command $clashdir/clash -d $clashdir
|
2020-08-03 15:16:33 +08:00
|
|
|
procd_close_instance
|
|
|
|
#修改iptables规则使流量进入clash
|
2020-08-09 13:51:37 +08:00
|
|
|
stop_iptables
|
2020-09-08 18:12:18 +08:00
|
|
|
[ "$redir_mod" != "纯净模式" ] && start_dns
|
|
|
|
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
|
2020-08-22 19:05:02 +08:00
|
|
|
#标记启动时间
|
2020-08-06 19:57:28 +08:00
|
|
|
mark_time
|
2020-08-22 19:05:02 +08:00
|
|
|
#标记启动方式
|
|
|
|
sed -i /start_old=*/d $ccfg
|
|
|
|
sed -i "1i\start_old=未开启" $ccfg
|
2020-08-03 15:16:33 +08:00
|
|
|
}
|
|
|
|
stop_service() {
|
2020-08-22 19:05:02 +08:00
|
|
|
source $clashdir/start.sh
|
2020-08-09 13:51:37 +08:00
|
|
|
stop_iptables
|
2020-08-03 15:16:33 +08:00
|
|
|
}
|