Skip to content

梅林插件的list持续更新方式

背景

路由器是梅林系统,由于各种问题,无法继续更新清单。

解决步骤

  1. https://github.com/qxzg/Actions 的源

其提供的办法

  1. 进入路由器SSH,运行以下命令会自动将ss_rule_update脚本中的url_main参数指向我的仓库(二选一即可):
  2. sed -i ‘s/^URL_MAIN.*/URL_MAIN="https:\/\/raw.githubusercontent.com\/qxzg\/Actions\/3.0\/fancyss_rules"/g’ /koolshare/scripts/ss_rule_update.sh (推荐,直连GitHub仓库)
  3. sed -i ‘s/^URL_MAIN.*/URL_MAIN="https:\/\/cdn.jsdelivr.net\/gh\/qxzg\/[email protected]\/fancyss_rules"/g’ /koolshare/scripts/ss_rule_update.sh (仅当更新规则时显示"没有检测到在线版本。可能是访问github有问题"时推荐,由于jsDelivr CDN存在最长24小时的缓存,规则更新会有延迟)
  4. x86版本fancyss插件请自行找到更新规则的脚本并替换url_main参数
  5. 每次fancyss插件更新后都需要重新运行一次更新ss_rule_update脚本的命令

个人建议直接提环内容,主要因为wget 命令对https访问出错,问题是openssl版本问题。
报错内容:

Resolving raw.githubusercontent.com... 2606:50c0:8003::154, 185.199.111.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com|2606:50c0:8003::154|:443... failed: Network is unreachable.
Connecting to raw.githubusercontent.com|185.199.111.133|:443... connected.
OpenSSL: error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
Unable to establish SSL connection.

最终使用curl修改后的源码。直接将以下内容替换/koolshare/scripts/ss_rule_update.sh

#!/bin/sh

# shadowsocks script for AM380 merlin firmware
# by sadog ([email protected]) from koolshare.cn

eval `dbus export ss`
source /koolshare/scripts/base.sh
alias echo_date='echo 【$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X)】:'

start_update(){
    url_main="https://raw.githubusercontent.com/qxzg/Actions/master/fancyss_rules"
    url_back=""
    # version dectet
    version_gfwlist1=$(cat /koolshare/ss/rules/version | sed -n 1p | sed 's/ /\n/g'| sed -n 1p)
    version_chnroute1=$(cat /koolshare/ss/rules/version | sed -n 2p | sed 's/ /\n/g'| sed -n 1p)
    version_cdn1=$(cat /koolshare/ss/rules/version | sed -n 4p | sed 's/ /\n/g'| sed -n 1p)

    echo ==================================================================================================
    echo_date 开始更新shadowsocks规则,请等待...
    curl "$url_main"/version1 -o /tmp/ss_version
    if [ "$?" == "0" ]; then
        echo_date 检测到在线版本文件,继续...
    else
        echo_date 没有检测到在线版本,可能是访问github有问题,去大陆白名单模式试试吧!
        rm -rf /tmp/ss_version
        exit
    fi

    online_content=$(cat /tmp/ss_version)
    if [ -z "$online_content" ];then
        rm -rf /tmp/ss_version
    fi

    git_line1=$(cat /tmp/ss_version | sed -n 1p)
    git_line2=$(cat /tmp/ss_version | sed -n 2p)
    git_line4=$(cat /tmp/ss_version | sed -n 4p)

    version_gfwlist2=$(echo $git_line1 | sed 's/ /\n/g'| sed -n 1p)
    version_chnroute2=$(echo $git_line2 | sed 's/ /\n/g'| sed -n 1p)
    version_cdn2=$(echo $git_line4 | sed 's/ /\n/g'| sed -n 1p)

    md5sum_gfwlist2=$(echo $git_line1 | sed 's/ /\n/g'| tail -n 2 | head -n 1)
    md5sum_chnroute2=$(echo $git_line2 | sed 's/ /\n/g'| tail -n 2 | head -n 1)
    md5sum_cdn2=$(echo $git_line4 | sed 's/ /\n/g'| tail -n 2 | head -n 1)

    # update gfwlist
    if [ "$ss_basic_gfwlist_update" == "1" ];then
        echo_date " --------------------------------------------------------------------"
        if [ ! -z "$version_gfwlist2" ];then
            if [ "$version_gfwlist1" != "$version_gfwlist2" ];then
                echo_date 检测到新版本gfwlist,开始更新...
                echo_date 下载gfwlist到临时文件...
                #wget --no-check-certificate --timeout=8 -qO - "$url_main"/gfwlist.conf > /tmp/gfwlist.conf
                                curl "$url_main"/gfwlist.conf -o /tmp/gfwlist.conf
                md5sum_gfwlist1=$(md5sum /tmp/gfwlist.conf | sed 's/ /\n/g'| sed -n 1p)
                if [ "$md5sum_gfwlist1"x = "$md5sum_gfwlist2"x ];then
                    echo_date 下载完成,校验通过,将临时文件覆盖到原始gfwlist文件
                    mv /tmp/gfwlist.conf /koolshare/ss/rules/gfwlist.conf
                    sed -i "1s/.*/$git_line1/" /koolshare/ss/rules/version
                    reboot="1"
                    echo_date 【更新成功】你的gfwlist已经更新到最新了哦~
                else
                    echo_date 下载完成,但是校验没有通过!
                fi
            else
                echo_date 检测到gfwlist本地版本号和在线版本号相同,不进行更新!
            fi
        else
            echo_date gfwlist文件下载失败!
        fi
    else
        echo_date 然而你并没有勾选gfwlist更新!
    fi

    # update chnroute
    if [ "$ss_basic_chnroute_update" == "1" ];then
        echo_date " --------------------------------------------------------------------"
        if [ ! -z "$version_chnroute2" ];then
            if [ "$version_chnroute1" != "$version_chnroute2" ];then
                echo_date 检测到新版本chnroute,开始更新...
                echo_date 下载chnroute到临时文件...
                curl "$url_main"/chnroute.txt -o /tmp/chnroute.txt
                md5sum_chnroute1=$(md5sum /tmp/chnroute.txt | sed 's/ /\n/g'| sed -n 1p)
                if [ "$md5sum_chnroute1"x = "$md5sum_chnroute2"x ];then
                    echo_date 下载完成,校验通过,将临时文件覆盖到原始chnroute文件
                    mv /tmp/chnroute.txt /koolshare/ss/rules/chnroute.txt
                    sed -i "2s/.*/$git_line2/" /koolshare/ss/rules/version
                    reboot="1"
                    echo_date 【更新成功】你的chnroute已经更新到最新了哦~
                else
                    echo_date md5sum 下载完成,但是校验没有通过!
                fi
            else
                echo_date 检测到chnroute本地版本号和在线版本号相同,不进行更新!
            fi
        else
            echo_date chnroute文件下载失败!
        fi
    else
        echo_date 然而你并没有勾选chnroute更新!
    fi

    # update cdn file
    if [ "$ss_basic_cdn_update" == "1" ];then
        echo_date " --------------------------------------------------------------------"
        if [ ! -z "$version_cdn2" ];then
            if [ "$version_cdn1" != "$version_cdn2" ];then
                echo_date 检测到新版本cdn名单,开始更新...
                echo_date 下载cdn名单到临时文件...
                curl "$url_main"/cdn.txt -o /tmp/cdn.txt
                md5sum_cdn1=$(md5sum /tmp/cdn.txt | sed 's/ /\n/g'| sed -n 1p)
                if [ "$md5sum_cdn1"x = "$md5sum_cdn2"x ];then
                    echo_date 下载完成,校验通过,将临时文件覆盖到原始cdn名单文件
                    mv /tmp/cdn.txt /koolshare/ss/rules/cdn.txt
                    sed -i "4s/.*/$git_line4/" /koolshare/ss/rules/version
                    reboot="1"
                    echo_date 【更新成功】你的cdn名单已经更新到最新了哦~
                else
                    echo_date 下载完成,但是校验没有通过!
                fi
            else
                echo_date 检测到cdn名单本地版本号和在线版本号相同,不进行更新!
            fi
        else
            echo_date cdn名单文件下载失败!
        fi
    else
        echo_date 然而你并没有勾选cdn名单更新!
    fi
    echo_date " --------------------------------------------------------------------"
    rm -rf /tmp/gfwlist.conf1
    rm -rf /tmp/chnroute.txt1
    rm -rf /tmp/cdn.txt1
    rm -rf /tmp/ss_version

    echo_date Shadowsocks更新进程运行完毕!
    # write number
    nvram set update_ipset="$(cat /koolshare/ss/rules/version | sed -n 1p | sed 's/#/\n/g'| sed -n 1p)"
    nvram set update_chnroute="$(cat /koolshare/ss/rules/version | sed -n 2p | sed 's/#/\n/g'| sed -n 1p)"
    nvram set update_cdn="$(cat /koolshare/ss/rules/version | sed -n 4p | sed 's/#/\n/g'| sed -n 1p)"

    nvram set ipset_numbers=$(cat /koolshare/ss/rules/gfwlist.conf | grep -c ipset)
    nvram set chnroute_numbers=$(cat /koolshare/ss/rules/chnroute.txt | grep -c .)
    nvram set cdn_numbers=$(cat /koolshare/ss/rules/cdn.txt | grep -c .)
    #======================================================================
    if [ "$reboot" == "1" ];then
        echo_date 自动重启shadowsocks,以应用新的规则文件!请稍后!
        dbus set ss_basic_action=1
        sh /koolshare/ss/ssconfig.sh restart
    fi
    echo ==================================================================================================
}

change_cru(){
    echo ==================================================================================================
    sed -i '/ssupdate/d' /var/spool/cron/crontabs/* >/dev/null 2>&1
    if [ "1" == "$ss_basic_rule_update" ]; then
        echo_date 应用ss规则定时更新任务:每天"$ss_basic_rule_update_time"自动检测更新规则.
        cru a ssupdate "0 $ss_basic_rule_update_time * * * /bin/sh /koolshare/scripts/ss_rule_update.sh"
    else
        echo_date ss规则定时更新任务未启用!
    fi
}

case $ss_basic_update_action in
1)
    #svae only
    change_cru
    # incase next time auto update failed
    dbus remove ss_basic_update_action
    ;;
2)
    #save and apply form we action
    ss_basic_gfwlist_update=1
    ss_basic_chnroute_update=1
    ss_basic_cdn_update=1
    change_cru
    start_update
    dbus remove ss_basic_update_action
    ;;
*)
    #this is for autoupdate
    change_cru
    start_update
    dbus remove ss_basic_update_action
    ;;
esac
发表评论

电子邮件地址不会被公开。 必填项已用*标注