mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 03:32:34 +08:00
v1.0.0beta9
~修复手动更新订阅功能出错的bug ~调整本机代理功能设置 ~修复GoogleHome无法使用的问题 ~调整启动脚本,适配旧版本设备 ~修复非Openwrt系统下定时任务不生效的bug ~修复保守模式守护进程不生效的bug ~优化更新订阅时的启动逻辑
This commit is contained in:
parent
93e74b5579
commit
cafef2f413
|
@ -6,7 +6,6 @@ getconfig(){
|
|||
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}';)
|
||||
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')
|
||||
[ -z $host ] && host=127.0.0.1
|
||||
fi
|
||||
|
@ -115,7 +114,8 @@ clashstart(){
|
|||
$clashdir/start.sh start
|
||||
sleep 1
|
||||
PID=$(pidof clash)
|
||||
if [ -z "$PID" ];then
|
||||
if [ -z "$PID" ];then
|
||||
$clashdir/start.sh stop
|
||||
echo -e "\033[31mclash启动失败!\033[0m"
|
||||
exit
|
||||
fi
|
||||
|
@ -793,9 +793,10 @@ clashcron(){
|
|||
read -p "是否确认添加定时任务?(1/0) > " res
|
||||
if [ "$res" = '1' ]; then
|
||||
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 -e "\033[31m定时任务已添加!!!\033[0m"
|
||||
chmod 600 $cronpath #修改权限
|
||||
fi
|
||||
clashcron
|
||||
}
|
||||
|
|
|
@ -5,29 +5,28 @@ START=92
|
|||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
USE_PROCD=1
|
||||
|
||||
DIR=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
||||
|
||||
start_service() {
|
||||
clashdir=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
||||
#使用procd创建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
|
||||
procd_set_param command $DIR/clash -d $DIR
|
||||
procd_close_instance
|
||||
#其他设置
|
||||
$clashdir/start.sh afstart
|
||||
$DIR/start.sh afstart
|
||||
}
|
||||
|
||||
start() {
|
||||
if [ -z "$(pidof procd)" ];then
|
||||
clashdir=$(cat /etc/profile|grep clashdir|awk -F "\"" '{print $2}')
|
||||
#创建后台进程
|
||||
service_start $clashdir/clash -d $clashdir
|
||||
#$clashdir/start.sh deamon
|
||||
service_start $DIR/clash -d $DIR
|
||||
#设置守护进程
|
||||
$DIR/start.sh deamon
|
||||
#其他设置
|
||||
$clashdir/start.sh afstart
|
||||
$DIR/start.sh afstart
|
||||
else
|
||||
start_service
|
||||
fi
|
||||
|
|
|
@ -117,28 +117,38 @@ else
|
|||
$0 stop
|
||||
start_over(){
|
||||
echo -e "\033[32mclash服务已启动!\033[0m"
|
||||
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if [ -d /www/clash ];then
|
||||
echo -e "请使用\033[30;47m http://$host/clash \033[0m管理内置规则"
|
||||
elif [ -d $clashdir/ui ];then
|
||||
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
|
||||
sleep 1
|
||||
PID=$(pidof clash)
|
||||
if [ -n "$PID" ];then
|
||||
if pidof clash >/dev/null;then
|
||||
start_over
|
||||
else
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if [ -f $yaml.bak ];then
|
||||
echo -e "\033[31mclash服务启动失败!已还原配置文件并重启clash!\033[0m"
|
||||
$clashdir/start.sh stop
|
||||
mv $yaml.bak $yaml
|
||||
$0 start
|
||||
echo -e "\033[31mclash服务启动失败!已还原配置文件并重启clash!\033[0m"
|
||||
sleep 1
|
||||
else
|
||||
echo -e "\033[31mclash服务启动失败!请查看报错信息!\033[0m"
|
||||
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
|
||||
if pidof clash >/dev/null;then
|
||||
start_over
|
||||
exit;
|
||||
fi
|
||||
fi
|
||||
echo -e "\033[31mclash服务启动失败!请查看报错信息!\033[0m"
|
||||
$clashdir/start.sh stop
|
||||
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
|
||||
exit;
|
||||
fi
|
||||
else
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -286,23 +296,21 @@ start_dns(){
|
|||
ip6tables -t nat -A PREROUTING -p udp -j clash_dns > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
daemon_old(){
|
||||
#守护进程状态
|
||||
PID=$(pidof clash)
|
||||
if [ -z "$PID" ];then
|
||||
$clashdir/clash -d $clashdir > /dev/null &
|
||||
mark_time
|
||||
fi
|
||||
}
|
||||
checkcron(){
|
||||
[ -d /etc/crontabs/ ]&&cronpath="/etc/crontabs/root"
|
||||
[ -d /var/spool/cron/ ]&&cronpath="/var/spool/cron/root"
|
||||
[ -d /var/spool/cron/crontabs/ ]&&cronpath="/var/spool/cron/crontabs/root"
|
||||
if [ -z $cronpath ];then
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo "找不到定时任务文件,无法添加定时任务!"
|
||||
clashsh
|
||||
fi
|
||||
[ -z $cronpath ]&&echo "找不到定时任务文件,无法添加定时任务!"
|
||||
}
|
||||
daemon(){
|
||||
checkcron
|
||||
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(){
|
||||
#读取配置文件
|
||||
|
@ -328,6 +336,7 @@ start)
|
|||
#使用不同方式启动clash服务
|
||||
if [ "$start_old" = "已开启" ];then
|
||||
$clashdir/clash -d $clashdir >/dev/null 2>&1 &
|
||||
daemon_old
|
||||
afstart
|
||||
elif [ -f /etc/rc.common ];then
|
||||
/etc/init.d/clash start
|
||||
|
@ -338,7 +347,7 @@ start)
|
|||
stop)
|
||||
#删除守护
|
||||
checkcron
|
||||
sed -i /start.sh/d $cronpath >/dev/null 2>&1
|
||||
sed -i /clash守护进程/d $cronpath
|
||||
#多种方式结束进程
|
||||
if [ -f /etc/rc.common ];then
|
||||
/etc/init.d/clash stop >/dev/null 2>&1
|
||||
|
@ -357,8 +366,8 @@ getyaml)
|
|||
getconfig
|
||||
getyaml
|
||||
;;
|
||||
daemon_old)
|
||||
daemon_old
|
||||
daemon)
|
||||
daemon
|
||||
;;
|
||||
esac
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user