From 4dc4607ea3f1859772be0642b1c6cc565557b9af Mon Sep 17 00:00:00 2001 From: juewuy Date: Wed, 16 Mar 2022 16:10:18 +0800 Subject: [PATCH] =?UTF-8?q?v1.5.5=20~=E5=85=A8=E9=9D=A2=E9=80=82=E9=85=8Da?= =?UTF-8?q?x6s=E7=AD=89=E5=B0=8F=E7=B1=B3=E9=95=9C=E5=83=8F=E5=8C=96?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E5=A4=87=20=20=20=C2=B7=E6=94=AF?= =?UTF-8?q?=E6=8C=81procd=E5=AE=88=E6=8A=A4=E8=BF=9B=E7=A8=8B=20=20=20?= =?UTF-8?q?=C2=B7=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E5=BC=80=E6=9C=BA?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=20=20=20=C2=B7=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=BC=80=E5=90=AFSSH=E5=8F=8A=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E8=BF=98=E5=8E=9FSSH=E7=A7=98=E9=92=A5=20~=E9=87=8D=E5=81=9A?= =?UTF-8?q?=E5=B0=8F=E7=B1=B3SSH=E5=B7=A5=E5=85=B7=EF=BC=8C=E7=8E=B0?= =?UTF-8?q?=E5=9C=A8=E6=94=AF=E6=8C=81=E5=90=84=E7=B1=BB=E5=B0=8F=E7=B1=B3?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E8=AE=BE=E5=A4=87=E8=BD=AF=E4=BB=B6=E5=9B=BA?= =?UTF-8?q?=E5=8C=96SSH(=E5=BE=85=E6=B5=8B=E8=AF=95)=20~=E9=87=8D=E5=86=99?= =?UTF-8?q?=E8=87=AA=E5=90=AF=E9=80=BB=E8=BE=91=EF=BC=8C=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81Padavan=E3=80=81=E6=A2=85=E6=9E=97=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E5=BC=80=E6=9C=BA=E5=90=AF=E5=8A=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clash.sh | 21 +++++++++++++++------ scripts/misnap_init.sh | 24 ++---------------------- scripts/start.sh | 19 ++++++++++++------- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/scripts/clash.sh b/scripts/clash.sh index 7c3b826..6a4ba19 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -1226,13 +1226,22 @@ tools(){ tools elif [ -f /usr/sbin/otapredownload ] && [ "$num" = 6 ]; then - [ "$mi_autoSSH" = "已启用" ] && mi_autoSSH=禁用 || mi_autoSSH=已启用 + if [ "$mi_autoSSH" = "已启用" ];then + mi_autoSSH=禁用 + else + echo ----------------------------------------------- + echo -e "\033[33m本功能使用软件命令进行固化不保证100%成功!\033[0m" + echo -e "本功能需依赖clash服务,请确保clash为开机启动状态!" + echo -e "\033[33m如有问题请加群反馈:\033[36;4mhttps://t.me/clashfm\033[0m" + mi_autoSSH=已启用 + if [ "$systype" = "mi_snapshot" ];then + cp -f /etc/dropbear/dropbear_rsa_host_key $clashdir/dropbear_rsa_host_key 2>/dev/null + echo -e "\033[32m检测当前为小米镜像化系统,已将SSH秘钥备份到脚本安装目录!\033[0m" + echo -e "\033[32mClash会在启动时自动还原已备份的秘钥文件!\033[0m" + fi + sleep 2 + fi setconfig mi_autoSSH $mi_autoSSH - echo ----------------------------------------------- - echo -e "\033[33m本功能使用软件命令进行固化不保证100%成功!\033[0m" - echo -e "本功能需依赖clash服务,请确保clash为开机启动状态!" - echo -e "\033[33m如有问题请加群反馈:\033[36;4mhttps://t.me/clashfm\033[0m" - sleep 2 tools else errornum diff --git a/scripts/misnap_init.sh b/scripts/misnap_init.sh index 84e2050..c5998e1 100644 --- a/scripts/misnap_init.sh +++ b/scripts/misnap_init.sh @@ -4,21 +4,6 @@ clashdir=/data/clash profile=/etc/profile -log(){ - dir=$clashdir/ui/log - echo `date`ssh状态获取 >> $dir - nvram get telnet_en >> $dir - nvram get ssh_en >> $dir - nvram get uart_en >> $dir - uci -c /usr/share/xiaoqiang get xiaoqiang_version.version.CHANNEL >> $dir - grep 'channel=.*' /etc/init.d/dropbear >> $dir - /etc/init.d/dropbear enabled - echo dropbear自启状态:$? >> $dir -} - -#还原SSH秘钥 -ln -sf $clashdir/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key - #h初始化环境变量 echo "alias clash=\"$clashdir/clash.sh\"" >> $profile echo "export clashdir=\"$clashdir\"" >> $profile @@ -27,9 +12,7 @@ echo "export clashdir=\"$clashdir\"" >> $profile ln -sf $clashdir/clashservice /etc/init.d/clash chmod 755 /etc/init.d/clash -log - -[ -f $clashdir/.dis_startup ] || { +if [ ! -f $clashdir/.dis_startup ];then log_file=`uci get system.@system[0].log_file` while [ "$i" -lt 10 ];do sleep 3 @@ -37,7 +20,4 @@ log done /etc/init.d/clash start /etc/init.d/clash enable -} - -sleep 10 -log +fi diff --git a/scripts/start.sh b/scripts/start.sh index 615066e..e31417f 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -121,15 +121,17 @@ steaming(){ } autoSSH(){ #自动开启SSH - echo `date`ssh状态设置 >> /data/clash/ui/log - nvram set telnet_en=1 - nvram set ssh_en=1 - nvram set uart_en=1 - nvram commit - uci -c /usr/share/xiaoqiang set xiaoqiang_version.version.CHANNEL='stable' + [ "$(nvram get ssh_en)" = 0 ] && nvram set ssh_en=1 && nvram commit + [ "`uci -c /usr/share/xiaoqiang get xiaoqiang_version.version.CHANNEL`" != 'stable' ] && { + uci -c /usr/share/xiaoqiang set xiaoqiang_version.version.CHANNEL='stable' uci -c /usr/share/xiaoqiang commit xiaoqiang_version.version + } + [ -z "$(pidof dropbear)" -o -z "$(netstat -ntul | grep :22)" ] && { sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear /etc/init.d/dropbear restart + } + #备份还原SSH秘钥 + [ -f $clashdir/dropbear_rsa_host_key ] && ln -sf $clashdir/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key } #配置文件相关 getyaml(){ @@ -805,7 +807,7 @@ afstart(){ cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置" [ -f $clashdir/web_save ] && web_restore & #后台还原面板配置 #自动开启SSH - [ "$mi_autoSSH" = "已启用" ] && [ -z "$(pidof dropbear)" -o -z "$(netstat -ntul | grep :22)" ] && autoSSH 2>/dev/null + [ "$mi_autoSSH" = "已启用" ] && autoSSH 2>/dev/null else logger "clash服务启动失败!请查看报错信息!" 31 $bindir/clash -t -d $bindir @@ -968,6 +970,9 @@ unset_proxy) steaming) steaming ;; +db) + $2 + ;; esac exit 0