From 9db967e5a7a6c9e9df719df3596e3d4af95ac7e8 Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Sun, 8 Feb 2026 23:13:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BF=AE=E6=94=B9=E5=9B=BD?= =?UTF-8?q?=E5=AE=B6=E5=92=8C=E5=9C=B0=E5=8C=BA=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Prometheus/install_Prometheus.sh | 6 ++---- Prometheus/install_cAdvisor.sh | 6 ++---- Prometheus/install_mysqld_exporter.sh | 6 ++---- Prometheus/install_node_exporter.sh | 3 --- Prometheus/install_node_exporter_arm64.sh | 9 +++------ 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Prometheus/install_Prometheus.sh b/Prometheus/install_Prometheus.sh index 36fd9e2..8f10731 100644 --- a/Prometheus/install_Prometheus.sh +++ b/Prometheus/install_Prometheus.sh @@ -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" diff --git a/Prometheus/install_cAdvisor.sh b/Prometheus/install_cAdvisor.sh index 091727d..ea5784b 100644 --- a/Prometheus/install_cAdvisor.sh +++ b/Prometheus/install_cAdvisor.sh @@ -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" diff --git a/Prometheus/install_mysqld_exporter.sh b/Prometheus/install_mysqld_exporter.sh index b4bb9be..d740236 100644 --- a/Prometheus/install_mysqld_exporter.sh +++ b/Prometheus/install_mysqld_exporter.sh @@ -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" diff --git a/Prometheus/install_node_exporter.sh b/Prometheus/install_node_exporter.sh index 1a8ae45..e143c35 100644 --- a/Prometheus/install_node_exporter.sh +++ b/Prometheus/install_node_exporter.sh @@ -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 diff --git a/Prometheus/install_node_exporter_arm64.sh b/Prometheus/install_node_exporter_arm64.sh index d10d108..e4c6182 100644 --- a/Prometheus/install_node_exporter_arm64.sh +++ b/Prometheus/install_node_exporter_arm64.sh @@ -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"