v1.0.0beta9
~修复手动更新订阅功能出错的bug ~调整本机代理功能设置 ~修复GoogleHome无法使用的问题 ~调整启动脚本,适配旧版本设备 ~修复非Openwrt系统下定时任务不生效的bug ~修复保守模式守护进程不生效的bug ~优化更新订阅时的启动逻辑
This commit is contained in:
@@ -6,7 +6,6 @@ getconfig(){
|
|||||||
if [ -f /bin/opkg ];then
|
if [ -f /bin/opkg ];then
|
||||||
host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
|
host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
|
||||||
else
|
else
|
||||||
cron_user='root '
|
|
||||||
host=$(ip a|grep -w 'inet'|grep 'global'|grep -E '192.|10.'|sed 's/.*inet.//g'|sed 's/\/[0-9][0-9].*$//g')
|
host=$(ip a|grep -w 'inet'|grep 'global'|grep -E '192.|10.'|sed 's/.*inet.//g'|sed 's/\/[0-9][0-9].*$//g')
|
||||||
[ -z $host ] && host=127.0.0.1
|
[ -z $host ] && host=127.0.0.1
|
||||||
fi
|
fi
|
||||||
@@ -116,6 +115,7 @@ clashstart(){
|
|||||||
sleep 1
|
sleep 1
|
||||||
PID=$(pidof clash)
|
PID=$(pidof clash)
|
||||||
if [ -z "$PID" ];then
|
if [ -z "$PID" ];then
|
||||||
|
$clashdir/start.sh stop
|
||||||
echo -e "\033[31mclash启动失败!\033[0m"
|
echo -e "\033[31mclash启动失败!\033[0m"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@@ -793,9 +793,10 @@ clashcron(){
|
|||||||
read -p "是否确认添加定时任务?(1/0) > " res
|
read -p "是否确认添加定时任务?(1/0) > " res
|
||||||
if [ "$res" = '1' ]; then
|
if [ "$res" = '1' ]; then
|
||||||
sed -i /$cronname/d $cronpath
|
sed -i /$cronname/d $cronpath
|
||||||
echo "$min $hour * * $week $cron_user$cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname" >> $cronpath
|
echo "$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname" >> $cronpath
|
||||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
echo -e "\033[31m定时任务已添加!!!\033[0m"
|
echo -e "\033[31m定时任务已添加!!!\033[0m"
|
||||||
|
chmod 600 $cronpath #修改权限
|
||||||
fi
|
fi
|
||||||
clashcron
|
clashcron
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,29 +5,28 @@ START=92
|
|||||||
SERVICE_DAEMONIZE=1
|
SERVICE_DAEMONIZE=1
|
||||||
SERVICE_WRITE_PID=1
|
SERVICE_WRITE_PID=1
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
DIR=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
clashdir=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
|
||||||
#使用procd创建clash后台进程
|
#使用procd创建clash后台进程
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_set_param stderr 1
|
procd_set_param stderr 1
|
||||||
procd_set_param stdout 1
|
procd_set_param stdout 1
|
||||||
procd_set_param command $clashdir/clash -d $clashdir
|
procd_set_param command $DIR/clash -d $DIR
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
#其他设置
|
#其他设置
|
||||||
$clashdir/start.sh afstart
|
$DIR/start.sh afstart
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if [ -z "$(pidof procd)" ];then
|
if [ -z "$(pidof procd)" ];then
|
||||||
clashdir=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
|
||||||
#创建后台进程
|
#创建后台进程
|
||||||
service_start $clashdir/clash -d $clashdir
|
service_start $DIR/clash -d $DIR
|
||||||
#$clashdir/start.sh deamon
|
#设置守护进程
|
||||||
|
$DIR/start.sh deamon
|
||||||
#其他设置
|
#其他设置
|
||||||
$clashdir/start.sh afstart
|
$DIR/start.sh afstart
|
||||||
else
|
else
|
||||||
start_service
|
start_service
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -117,28 +117,38 @@ else
|
|||||||
$0 stop
|
$0 stop
|
||||||
start_over(){
|
start_over(){
|
||||||
echo -e "\033[32mclash服务已启动!\033[0m"
|
echo -e "\033[32mclash服务已启动!\033[0m"
|
||||||
echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理内置规则"
|
if [ -d /www/clash ];then
|
||||||
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m 9999 \033[0m"
|
echo -e "请使用\033[30;47m http://$host/clash \033[0m管理内置规则"
|
||||||
echo -e "也可前往更新菜单安装本地Dashboard面板,连接更稳定!\033[0m"
|
elif [ -d $clashdir/ui ];then
|
||||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
echo -e "请使用\033[30;47m http://$host:9999/ui \033[0m管理内置规则"
|
||||||
|
else
|
||||||
|
echo -e "可使用\033[30;47m http://clash.razord.top \033[0m管理内置规则"
|
||||||
|
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m 9999 \033[0m"
|
||||||
|
echo -e "也可前往更新菜单安装本地Dashboard面板,连接更稳定!\033[0m"
|
||||||
|
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
$0 start
|
$0 start
|
||||||
sleep 1
|
sleep 1
|
||||||
PID=$(pidof clash)
|
if pidof clash >/dev/null;then
|
||||||
if [ -n "$PID" ];then
|
|
||||||
start_over
|
start_over
|
||||||
else
|
else
|
||||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
if [ -f $yaml.bak ];then
|
if [ -f $yaml.bak ];then
|
||||||
echo -e "\033[31mclash服务启动失败!已还原配置文件并重启clash!\033[0m"
|
$clashdir/start.sh stop
|
||||||
mv $yaml.bak $yaml
|
mv $yaml.bak $yaml
|
||||||
$0 start
|
$0 start
|
||||||
|
echo -e "\033[31mclash服务启动失败!已还原配置文件并重启clash!\033[0m"
|
||||||
sleep 1
|
sleep 1
|
||||||
else
|
if pidof clash >/dev/null;then
|
||||||
echo -e "\033[31mclash服务启动失败!请查看报错信息!\033[0m"
|
start_over
|
||||||
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
|
|
||||||
exit;
|
exit;
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo -e "\033[31mclash服务启动失败!请查看报错信息!\033[0m"
|
||||||
|
$clashdir/start.sh stop
|
||||||
|
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
|
||||||
|
exit;
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -286,23 +296,21 @@ start_dns(){
|
|||||||
ip6tables -t nat -A PREROUTING -p udp -j clash_dns > /dev/null 2>&1
|
ip6tables -t nat -A PREROUTING -p udp -j clash_dns > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
daemon_old(){
|
|
||||||
#守护进程状态
|
|
||||||
PID=$(pidof clash)
|
|
||||||
if [ -z "$PID" ];then
|
|
||||||
$clashdir/clash -d $clashdir > /dev/null &
|
|
||||||
mark_time
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
checkcron(){
|
checkcron(){
|
||||||
[ -d /etc/crontabs/ ]&&cronpath="/etc/crontabs/root"
|
[ -d /etc/crontabs/ ]&&cronpath="/etc/crontabs/root"
|
||||||
[ -d /var/spool/cron/ ]&&cronpath="/var/spool/cron/root"
|
[ -d /var/spool/cron/ ]&&cronpath="/var/spool/cron/root"
|
||||||
[ -d /var/spool/cron/crontabs/ ]&&cronpath="/var/spool/cron/crontabs/root"
|
[ -d /var/spool/cron/crontabs/ ]&&cronpath="/var/spool/cron/crontabs/root"
|
||||||
if [ -z $cronpath ];then
|
[ -z $cronpath ]&&echo "找不到定时任务文件,无法添加定时任务!"
|
||||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
}
|
||||||
echo "找不到定时任务文件,无法添加定时任务!"
|
daemon(){
|
||||||
clashsh
|
checkcron
|
||||||
fi
|
echo '*/1 * * * * test -z "$(pidof clash)" && /etc/init.d/clash start #clash守护进程' >> $cronpath
|
||||||
|
chmod 600 $cronpath
|
||||||
|
}
|
||||||
|
daemon_old(){
|
||||||
|
checkcron
|
||||||
|
echo '*/1 * * * * test -z "$(pidof clash)" && '"$clashdir/clash -d $clashdir >/dev/null 2>&1 & #clash守护进程" >> $cronpath
|
||||||
|
chmod 600 $cronpath
|
||||||
}
|
}
|
||||||
afstart(){
|
afstart(){
|
||||||
#读取配置文件
|
#读取配置文件
|
||||||
@@ -328,6 +336,7 @@ start)
|
|||||||
#使用不同方式启动clash服务
|
#使用不同方式启动clash服务
|
||||||
if [ "$start_old" = "已开启" ];then
|
if [ "$start_old" = "已开启" ];then
|
||||||
$clashdir/clash -d $clashdir >/dev/null 2>&1 &
|
$clashdir/clash -d $clashdir >/dev/null 2>&1 &
|
||||||
|
daemon_old
|
||||||
afstart
|
afstart
|
||||||
elif [ -f /etc/rc.common ];then
|
elif [ -f /etc/rc.common ];then
|
||||||
/etc/init.d/clash start
|
/etc/init.d/clash start
|
||||||
@@ -338,7 +347,7 @@ start)
|
|||||||
stop)
|
stop)
|
||||||
#删除守护
|
#删除守护
|
||||||
checkcron
|
checkcron
|
||||||
sed -i /start.sh/d $cronpath >/dev/null 2>&1
|
sed -i /clash守护进程/d $cronpath
|
||||||
#多种方式结束进程
|
#多种方式结束进程
|
||||||
if [ -f /etc/rc.common ];then
|
if [ -f /etc/rc.common ];then
|
||||||
/etc/init.d/clash stop >/dev/null 2>&1
|
/etc/init.d/clash stop >/dev/null 2>&1
|
||||||
@@ -357,8 +366,8 @@ getyaml)
|
|||||||
getconfig
|
getconfig
|
||||||
getyaml
|
getyaml
|
||||||
;;
|
;;
|
||||||
daemon_old)
|
daemon)
|
||||||
daemon_old
|
daemon
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
Reference in New Issue
Block a user