From de571b58e3aba26fdfc0d91b193ae48f008cb858 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sun, 15 Nov 2020 13:01:29 +0800 Subject: [PATCH] =?UTF-8?q?v1.0.0beta17.2=20~=E4=BF=AE=E5=A4=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=9C=A8=E7=BA=BF=E8=8A=82=E7=82=B9=E6=97=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84bug=20~=E4=BF=AE=E5=A4=8D=E6=89=8B=E5=8A=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=AE=A2=E9=98=85=E7=95=8C=E9=9D=A2=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E4=BF=9D=E5=AD=98=E9=93=BE=E6=8E=A5=E7=9A=84?= =?UTF-8?q?bug=20~=E4=B8=8B=E8=BD=BDdashboard=E9=9D=A2=E6=9D=BF=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8F=AF=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clash.sh | 6 ++++-- scripts/clashservice | 3 ++- scripts/getdate.sh | 51 +++++++++++++++++++------------------------- scripts/start.sh | 13 ++++++----- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/scripts/clash.sh b/scripts/clash.sh index e0ebb5c..a556453 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -80,6 +80,8 @@ getconfig(){ sed -i "1i\userguide=1" $ccfg [ "$res" = 1 ] && source $clashdir/getdate.sh && userguide fi + #检查执行权限 + [ ! -x $clashdir/start.sh ] && chmod +x $clashdir/start.sh } setconfig(){ #参数1代表变量名,参数2代表变量值,参数3即文件路径 @@ -95,9 +97,9 @@ errornum(){ startover(){ echo -e "\033[32mclash服务已启动!\033[0m" if [ -n "$hostdir" ];then - echo -e "请使用\033[4;32mhttp://$host$hostdir\033[0m管理内置规则" + echo -e "请使用 \033[4;32mhttp://$host$hostdir\033[0m 管理内置规则" else - echo -e "可使用\033[4;32mhttp://clash.razord.top\033[0m管理内置规则" + echo -e "可使用 \033[4;32mhttp://clash.razord.top\033[0m 管理内置规则" echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m $db_port \033[0m" echo -e "推荐前往更新菜单安装本地Dashboard面板,连接更稳定!\033[0m" fi diff --git a/scripts/clashservice b/scripts/clashservice index bc31d97..da9a3d8 100644 --- a/scripts/clashservice +++ b/scripts/clashservice @@ -1,12 +1,13 @@ #!/bin/sh /etc/rc.common -START=92 +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/mark | grep bindir | awk -F "=" '{print $2}') [ -z "$BINDIR" ] && BINDIR=$DIR diff --git a/scripts/getdate.sh b/scripts/getdate.sh index d3e0465..e2bf85b 100644 --- a/scripts/getdate.sh +++ b/scripts/getdate.sh @@ -295,18 +295,6 @@ clashlink(){ getlink elif [ "$num" = 2 ];then - if [ -n "$Url" ];then - echo ----------------------------------------------- - echo -e "\033[33m检测到已记录的订阅链接:\033[0m" - echo -e "\033[4;32m$Url\033[0m" - echo ----------------------------------------------- - read -p "清空链接/追加导入?[1/0] > " res - if [ "$res" = '1' ]; then - Url="" - echo ----------------------------------------------- - echo -e "\033[31m链接已清空!\033[0m" - fi - fi getlink2 elif [ "$num" = 3 ];then @@ -354,7 +342,7 @@ clashlink(){ else echo ----------------------------------------------- echo -e "\033[33m当前系统记录的订阅链接为:\033[0m" - echo -e "\033[4;32m$Url\033[0m" + echo -e "\033[4;32m$Url$Https\033[0m" echo ----------------------------------------------- read -p "确认更新配置文件?[1/0] > " res if [ "$res" = '1' ]; then @@ -600,25 +588,30 @@ getdb(){ errornum update fi - echo ----------------------------------------------- - echo -e "请选择面板\033[33m安装目录:\033[0m" - echo ----------------------------------------------- - echo -e " 1 在$clashdir/ui目录安装(推荐!安装后会自动重启clash服务!)" - echo -e " 2 在/www/clash目录安装(依赖Openwrt的Nginx服务,可能失败!)" - echo ----------------------------------------------- - echo " 0 返回上级菜单" - read -p "请输入对应数字 > " num + if [ -w /www/clash ];then + echo ----------------------------------------------- + echo -e "请选择面板\033[33m安装目录:\033[0m" + echo ----------------------------------------------- + echo -e " 1 在$clashdir/ui目录安装" + echo -e " 2 在/www/clash目录安装(推荐!)" + echo ----------------------------------------------- + echo " 0 返回上级菜单" + read -p "请输入对应数字 > " num - if [ -z "$num" ];then - update - elif [ "$num" = '1' ]; then - dbdir=$clashdir/ui - hostdir=":$db_port/ui" - elif [ "$num" = '2' ]; then + if [ -z "$num" ];then + update + elif [ "$num" = '1' ]; then + dbdir=$clashdir/ui + hostdir=":$db_port/ui" + elif [ "$num" = '2' ]; then + dbdir=/www/clash + hostdir='/clash' + else + update + fi + else dbdir=/www/clash hostdir='/clash' - else - update fi #下载及安装 if [ -d /www/clash -o -d $clashdir/ui ];then diff --git a/scripts/start.sh b/scripts/start.sh index c9cc6c9..ebd046c 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -55,7 +55,7 @@ webget(){ [ "$3" = "echoon" ] && progress='' [ -z "$4" ] && redirect='' || redirect='--max-redirect=0' wget -Y on $progress $redirect --no-check-certificate --timeout=5 -O $1 $2 - [ $? -eq 0 ] && result="200" + [ "$?" = 0 ] && result="200" fi export all_proxy='' } @@ -148,8 +148,8 @@ EOF` fi else Https="" - #检测节点 - if [ -z "$(cat $yamlnew | grep 'server:' | grep -v 'nameserver')" ];then + #检测节点或providers + if [ -z "$(cat $yamlnew | grep -E 'server:|proxy-providers:' | grep -v 'nameserver')" ];then echo ----------------------------------------------- logger "获取到了配置文件,但似乎并不包含正确的节点信息!" 31 echo ----------------------------------------------- @@ -182,8 +182,7 @@ EOF` mv -f $yamlnew $yaml fi echo 配置文件已生成!正在启动clash使其生效! - #重启clash服务 - $0 stop + #启动clash服务 $0 start if [ "$?" = 0 ];then logger "配置文件获取成功!clash服务已启动!" @@ -489,7 +488,7 @@ bfstart(){ #检查clash核心 if [ ! -f $bindir/clash ];then if [ -f $clashdir/clash ];then - mv $clashdir/clash $bindir/clash && chmod 777 $bindir/clash + mv $clashdir/clash $bindir/clash && chmod +x $bindir/clash else logger "未找到clash核心,正在下载!" 33 [ -z "$clashcore" ] && [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ] && clashcore=clashpre || clashcore=clash @@ -613,7 +612,7 @@ getyaml) getyaml ;; webget) - webget $1 $2 $3 $4 + webget $2 $3 $4 $5 ;; web_save) getconfig