统一修改国家和地区的判断方式
This commit is contained in:
@@ -27,13 +27,11 @@ TARGET="/tmp/prometheus-3.9.1.linux-amd64.tar.gz"
|
||||
is_cn=false
|
||||
|
||||
echo "Detecting geographic location..."
|
||||
COUNTRY=$(curl -s --max-time 5 https://ipinfo.littlediary.cn/info | grep -o '"countryName":"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
COUNTRY=$(curl -s --max-time 3 https://ipinfo.io/country || true)
|
||||
if [ "$COUNTRY" = "CN" ]; then
|
||||
if [ "$COUNTRY" = "China" ]; then
|
||||
is_cn=true
|
||||
fi
|
||||
|
||||
|
||||
if [ "$is_cn" = true ]; then
|
||||
echo "Geolocation: China mainland detected"
|
||||
DOWNLOAD_URL="$CN_URL"
|
||||
|
||||
@@ -24,13 +24,11 @@ TARGET=/tmp/cAdvisor
|
||||
is_cn=false
|
||||
|
||||
echo "Detecting geographic location..."
|
||||
COUNTRY=$(curl -s --max-time 5 https://ipinfo.littlediary.cn/info | grep -o '"countryName":"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
COUNTRY=$(curl -s --max-time 3 https://ipinfo.io/country || true)
|
||||
if [ "$COUNTRY" = "CN" ]; then
|
||||
if [ "$COUNTRY" = "China" ]; then
|
||||
is_cn=true
|
||||
fi
|
||||
|
||||
|
||||
if [ "$is_cn" = true ]; then
|
||||
echo "Geolocation: China mainland detected"
|
||||
DOWNLOAD_URL="$CN_URL"
|
||||
|
||||
@@ -27,13 +27,11 @@ TARGET="/tmp/mysqld_exporter-0.18.0.linux-amd64.tar.gz"
|
||||
is_cn=false
|
||||
|
||||
echo "Detecting geographic location..."
|
||||
COUNTRY=$(curl -s --max-time 5 https://ipinfo.littlediary.cn/info | grep -o '"countryName":"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
COUNTRY=$(curl -s --max-time 3 https://ipinfo.io/country || true)
|
||||
if [ "$COUNTRY" = "CN" ]; then
|
||||
if [ "$COUNTRY" = "China" ]; then
|
||||
is_cn=true
|
||||
fi
|
||||
|
||||
|
||||
if [ "$is_cn" = true ]; then
|
||||
echo "Geolocation: China mainland detected"
|
||||
DOWNLOAD_URL="$CN_URL"
|
||||
|
||||
@@ -27,7 +27,6 @@ TARGET="/tmp/node_exporter.tar.gz"
|
||||
is_cn=false
|
||||
|
||||
echo "Detecting geographic location..."
|
||||
|
||||
COUNTRY=$(curl -s --max-time 5 https://ipinfo.littlediary.cn/info | grep -o '"countryName":"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
if [ "$COUNTRY" = "China" ]; then
|
||||
@@ -45,8 +44,6 @@ echo "Downloading from: $DOWNLOAD_URL"
|
||||
curl -fL -o "$TARGET" "$DOWNLOAD_URL"
|
||||
|
||||
|
||||
|
||||
|
||||
# Extract
|
||||
echo "Extracting Node Exporter..."
|
||||
tar -zxvf /tmp/node_exporter.tar.gz -C /tmp
|
||||
|
||||
@@ -27,15 +27,11 @@ TARGET="/tmp/node_exporter.tar.gz"
|
||||
is_cn=false
|
||||
|
||||
echo "Detecting geographic location..."
|
||||
API_URL="https://ipinfo.littlediary.cn/info"
|
||||
JSON=$(curl -s --max-time 5 "$API_URL")
|
||||
COUNTRY=$(echo "$JSON" | grep -o '"country":"[^"]*"' | cut -d'"' -f4)
|
||||
COUNTRY=$(curl -s --max-time 5 https://ipinfo.littlediary.cn/info | grep -o '"countryName":"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
if [ "$COUNTRY" = "CN" ]; then
|
||||
if [ "$COUNTRY" = "China" ]; then
|
||||
is_cn=true
|
||||
fi
|
||||
|
||||
|
||||
if [ "$is_cn" = true ]; then
|
||||
echo "Geolocation: China mainland detected"
|
||||
DOWNLOAD_URL="$CN_URL"
|
||||
@@ -44,6 +40,7 @@ else
|
||||
DOWNLOAD_URL="$GLOBAL_URL"
|
||||
fi
|
||||
|
||||
|
||||
echo "Downloading from: $DOWNLOAD_URL"
|
||||
curl -fL -o "$TARGET" "$DOWNLOAD_URL"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user