From 1e91d11125196c98b6b0cb57d307946520164f0f Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 24 Feb 2023 17:22:22 +0800 Subject: [PATCH] Update mw.tpl --- scripts/init.d/mw.tpl | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 3fefb9d11..8bcc96826 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -196,32 +196,44 @@ error_logs() mw_update() { - cn=$(curl --insecure -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") - if [ ! -z "$cn" ];then - curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash - else + LOCAL_ADDR=common + ping -c 1 github.com > /dev/null 2>&1 + if [ "$?" != "0" ];then + LOCAL_ADDR=cn + fi + if [ "$LOCAL_ADDR" == "common" ];then curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash + else + curl --insecure -fsSL https://gitee.com/midoks/mdserver-web/raw/master/scripts/install.sh | bash fi } mw_update_dev() { - cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") - if [ ! -z "$cn" ];then - curl --insecure -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/update_dev.sh | bash - else + LOCAL_ADDR=common + ping -c 1 github.com > /dev/null 2>&1 + if [ "$?" != "0" ];then + LOCAL_ADDR=cn + fi + if [ "$LOCAL_ADDR" == "common" ];then curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash + else + curl --insecure -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/update_dev.sh | bash fi cd /www/server/mdserver-web } mw_mirror() { - cn=$(curl --insecure -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") - if [ ! -z "$cn" ];then - bash <(curl --insecure -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) - else + LOCAL_ADDR=common + ping -c 1 github.com > /dev/null 2>&1 + if [ "$?" != "0" ];then + LOCAL_ADDR=cn + fi + if [ "$LOCAL_ADDR" == "common" ];then bash <(curl --insecure -sSL https://raw.githubusercontent.com/midoks/change-linux-mirrors/main/change-mirrors.sh) + else + bash <(curl --insecure -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) fi cd /www/server/mdserver-web }