根据判断自动使用镜像地址
This commit is contained in:
@@ -53,7 +53,6 @@ info() {
|
|||||||
geo_check() {
|
geo_check() {
|
||||||
api_list="https://blog.cloudflare.com/cdn-cgi/trace https://dash.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace"
|
api_list="https://blog.cloudflare.com/cdn-cgi/trace https://dash.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace"
|
||||||
ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
|
ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
|
||||||
set -- "$api_list"
|
|
||||||
for url in $api_list; do
|
for url in $api_list; do
|
||||||
text="$(curl -A "$ua" -m 10 -s "$url")"
|
text="$(curl -A "$ua" -m 10 -s "$url")"
|
||||||
endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')"
|
endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')"
|
||||||
@@ -70,52 +69,19 @@ pre_check() {
|
|||||||
umask 077
|
umask 077
|
||||||
|
|
||||||
## os_arch
|
## os_arch
|
||||||
if uname -m | grep -q 'x86_64'; then
|
case "$(uname -m)" in
|
||||||
os_arch="amd64"
|
x86_64) os_arch="amd64" ;;
|
||||||
elif uname -m | grep -q 'i386\|i686'; then
|
i386|i686) os_arch="386" ;;
|
||||||
os_arch="386"
|
aarch64|armv8b|armv8l) os_arch="arm64" ;;
|
||||||
elif uname -m | grep -q 'aarch64\|armv8b\|armv8l'; then
|
arm*) os_arch="arm" ;;
|
||||||
os_arch="arm64"
|
s390x) os_arch="s390x" ;;
|
||||||
elif uname -m | grep -q 'arm'; then
|
riscv64) os_arch="riscv64" ;;
|
||||||
os_arch="arm"
|
esac
|
||||||
elif uname -m | grep -q 's390x'; then
|
|
||||||
os_arch="s390x"
|
|
||||||
elif uname -m | grep -q 'riscv64'; then
|
|
||||||
os_arch="riscv64"
|
|
||||||
fi
|
|
||||||
|
|
||||||
## China_IP
|
## China_IP 自动切换
|
||||||
if [ -z "$CN" ]; then
|
if [ "${isCN:-false}" = true ]; then
|
||||||
geo_check
|
GITHUB_URL="https://gh-proxy.com/https://github.com"
|
||||||
if [ -n "$isCN" ]; then
|
echo "检测到中国IP,已将 GITHUB_URL 修改为: $GITHUB_URL"
|
||||||
echo "根据geoip api提供的信息,当前IP可能在中国"
|
|
||||||
printf "是否选用中国镜像完成安装? [Y/n] (自定义镜像输入 3):"
|
|
||||||
read -r input
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS] | [yY])
|
|
||||||
echo "使用中国镜像"
|
|
||||||
CN=true
|
|
||||||
;;
|
|
||||||
|
|
||||||
[nN][oO] | [nN])
|
|
||||||
echo "不使用中国镜像"
|
|
||||||
;;
|
|
||||||
|
|
||||||
[3])
|
|
||||||
echo "使用自定义镜像"
|
|
||||||
printf "请输入自定义镜像 (例如:dn-dao-github-mirror.daocloud.io),留空为不使用:"
|
|
||||||
read -r input
|
|
||||||
case $input in
|
|
||||||
*)
|
|
||||||
CUSTOM_MIRROR=$input
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "不使用中国镜像"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user