From 7af4a5efefab23671f173044e7d6d78d99068f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Wed, 24 Sep 2025 11:18:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(install):=20=E6=A3=80=E6=B5=8B=E4=B8=AD?= =?UTF-8?q?=E5=9B=BD=E7=BD=91=E7=BB=9C=E7=8E=AF=E5=A2=83=E5=B9=B6=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=9B=BD=E5=86=85=E9=95=9C=E5=83=8F=E5=AE=89=E8=A3=85?= =?UTF-8?q?=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/1.sh b/1.sh index 89d567a..65944de 100644 --- a/1.sh +++ b/1.sh @@ -64,6 +64,24 @@ sysctl_config() { sysctl -p } +detect_cn_network() { + local check_urls=( + "https://developers.cloudflare.com/cdn-cgi/trace" + "https://ipinfo.io" + ) + + for check_url in "${check_urls[@]}"; do + local response + response=$(curl -fsSL "$check_url" || true) + if echo "$response" | grep -q "CN"; then + echo "检测到中国网络环境 (来源: $check_url)" + return 0 + fi + done + + return 1 +} + install_docker() { print_green "###################" print_green "##### docker ######" @@ -74,7 +92,13 @@ install_docker() { echo "Docker 未安装,正在安装中..." if [ "$SYSTEM_TYPE" = "debian" ]; then echo "在 Debian 系统上安装 Docker..." - curl -fsSL https://get.docker.com/ | sh + if detect_cn_network; then + echo "使用 cloudlayer.icu 安装脚本" + curl -fsSL https://cloudlayer.icu/docker-install.sh | sh + else + echo "使用官方 Docker 安装脚本" + curl -fsSL https://get.docker.com/ | sh + fi elif [ "$SYSTEM_TYPE" = "alpine" ]; then echo "在 Alpine 系统上安装 Docker..." apk add --no-cache docker