From 78d8fa7ebfaae38eedc0f78df2e356da5525f84d Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 29 Jun 2023 10:54:26 +0800 Subject: [PATCH] Update lib.sh --- scripts/lib.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 26ba4acf1..c5f20e833 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -57,15 +57,20 @@ else fi +# HTTP_PREFIX="https://" +# LOCAL_ADDR=common +# ping -c 1 github.com > /dev/null 2>&1 +# if [ "$?" != "0" ];then +# LOCAL_ADDR=cn +# HTTP_PREFIX="https://ghproxy.com/" +# fi + +cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" LOCAL_ADDR=common -ping -c 1 ipinfo.io > /dev/null 2>&1 -if [ "$?" == "0" ];then - CN=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") - if [ ! -z "$CN" ];then - LOCAL_ADDR=cn - HTTP_PREFIX="https://ghproxy.com/" - fi +if [ ! -z "$cn" ];then + LOCAL_ADDR=cn + HTTP_PREFIX="https://ghproxy.com/" fi PIPSRC="https://pypi.python.org/simple"