From 7ec50f9c68b6543a93978c7674e3addd8bb339be Mon Sep 17 00:00:00 2001 From: newton_miku <29966140+newton-miku@users.noreply.github.com> Date: Sat, 20 Jul 2024 22:46:50 +0800 Subject: [PATCH] Update install.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新install.sh,更换ip地址检测为b站源 --- install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 74f3d335..49c6bbe0 100755 --- a/install.sh +++ b/install.sh @@ -17,15 +17,17 @@ fi TMPDIR=$(mktemp -d) || exit 1 # GitHub mirror -ip_info=$(curl -sk https://ip.cooluc.com) -country_code=$(echo $ip_info | sed -r 's/.*country_code":"([^"]*).*/\1/') -if [ $country_code = "CN" ]; then - google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204) - if [ ! $google_status = "204" ];then - mirror="https://gh.cooluc.com/" - fi +ip_info=$(curl -sk https://api.live.bilibili.com/client/v1/Ip/getInfoNew) +country=$(echo $ip_info | sed -n 's/.*"country":"\([^"]*\)".*/\1/p') +if [ "$country" = "中国" ]; then + google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204) + if [ ! $google_status = "204" ]; then + mirror="https://gh.cooluc.com/" + echo -e "\r\n${GREEN_COLOR}已启用GitHub镜像${RES}\r\n" + fi fi + # Check CHECK() ( echo -e "\r\n${GREEN_COLOR}Checking available space ...${RES}"