@@ -30,6 +30,15 @@ without_cdn="false"
3030if [[ " ${WITHOUTCDN^^} " == " TRUE" ]]; then
3131 without_cdn=" true"
3232fi
33+ # 支持的环境变量(一键非交互安装):
34+ # WITHOUTCDN=true - 禁用 CDN 加速
35+ # CN=true - 强制使用中国镜像源
36+ # CN=false - 强制不使用中国镜像源(跳过检测)
37+ # IPV6_MAXIMUM_SUBSET=y/n - 是否使用 IPv6 最大子网范围(SLAAC 场景)
38+ # NEED_DISK_LIMIT=y/n - 是否启用容器磁盘大小限制(btrfs)
39+ # DOCKER_INSTALL_PATH=... - Docker 数据目录(默认 /var/lib/docker)
40+ # DOCKER_POOL_SIZE=20 - Docker 存储池大小(单位 GB,需 NEED_DISK_LIMIT=y)
41+ # DOCKER_LOOP_FILE=... - Docker loop 文件路径(默认 /opt/docker-pool.img)
3342
3443temp_file_apt_fix=" /tmp/apt_fix.txt"
3544REGEX=(" debian" " ubuntu" " centos|red hat|kernel|oracle linux|alma|rocky" " 'amazon linux'" " fedora" " arch" " alpine" )
@@ -445,6 +454,14 @@ get_system_arch() {
445454
446455check_china () {
447456 _yellow " IP area being detected ......"
457+ if [[ " ${CN^^} " == " TRUE" ]]; then
458+ _yellow " CN=TRUE detected, using Chinese mirrors"
459+ CN=true
460+ return
461+ elif [[ " ${CN^^} " == " FALSE" ]]; then
462+ _yellow " CN=FALSE detected, skipping Chinese mirrors"
463+ return
464+ fi
448465 if [[ -z " ${CN} " ]]; then
449466 if [[ $( curl -m 6 -s https://ipapi.co/json | grep ' China' ) != " " ]]; then
450467 _yellow " 根据ipapi.co提供的信息,当前IP可能在中国"
@@ -857,7 +874,15 @@ if [[ -n "$ipv6_address" ]]; then
857874 _blue " It is detected that IPV6 addresses are most likely to be dynamically assigned by SLAAC, and if there is no subsequent need to assign separate IPV6 addresses to VMs/containers, the following option is best selected n"
858875 _green " 检测到IPV6地址大概率由SLAAC动态分配,若后续不需要分配独立的IPV6地址给虚拟机/容器,则下面选项最好选 n, 选择 y 有概率导致宿主机丢失网络"
859876 _blue " Is the maximum subnet range feasible with IPV6 used?([n]/y)"
860- reading " 是否使用IPV6可行的最大子网范围?([n]/y)" select_maximum_subset
877+ if [[ " ${IPV6_MAXIMUM_SUBSET^^} " == " Y" || " ${IPV6_MAXIMUM_SUBSET^^} " == " TRUE" ]]; then
878+ _yellow " IPV6_MAXIMUM_SUBSET=${IPV6_MAXIMUM_SUBSET} detected, using maximum IPv6 subnet"
879+ select_maximum_subset=" y"
880+ elif [[ " ${IPV6_MAXIMUM_SUBSET^^} " == " N" || " ${IPV6_MAXIMUM_SUBSET^^} " == " FALSE" ]]; then
881+ _yellow " IPV6_MAXIMUM_SUBSET=${IPV6_MAXIMUM_SUBSET} detected, skipping maximum IPv6 subnet"
882+ select_maximum_subset=" n"
883+ else
884+ reading " 是否使用IPV6可行的最大子网范围?([n]/y)" select_maximum_subset
885+ fi
861886 if [ " $select_maximum_subset " = " y" ] || [ " $select_maximum_subset " = " Y" ]; then
862887 echo " true" > /usr/local/bin/docker_maximum_subset
863888 else
@@ -900,26 +925,46 @@ _blue "If you choose 'y', you can limit the disk space for each container"
900925_blue " If you choose 'n', standard Docker installation without disk limits"
901926_blue " 如果选择 'y',可以为每个容器限制磁盘空间"
902927_blue " 如果选择 'n',则为标准Docker安装,无磁盘限制"
903- reading " Do you need container disk size limitation? ([n]/y): " need_disk_limit
928+ if [[ -n " ${NEED_DISK_LIMIT} " ]]; then
929+ _yellow " NEED_DISK_LIMIT=${NEED_DISK_LIMIT} detected, skipping prompt"
930+ need_disk_limit=" ${NEED_DISK_LIMIT} "
931+ else
932+ reading " Do you need container disk size limitation? ([n]/y): " need_disk_limit
933+ fi
904934_green " Where do you want to install Docker? (Enter to default: /var/lib/docker):"
905- reading " Docker安装路径?(回车则默认:/var/lib/docker):" docker_install_path
935+ if [[ -n " ${DOCKER_INSTALL_PATH} " ]]; then
936+ _yellow " DOCKER_INSTALL_PATH=${DOCKER_INSTALL_PATH} detected, skipping prompt"
937+ docker_install_path=" ${DOCKER_INSTALL_PATH} "
938+ else
939+ reading " Docker安装路径?(回车则默认:/var/lib/docker):" docker_install_path
940+ fi
906941if [ -z " $docker_install_path " ]; then
907942 docker_install_path=" /var/lib/docker"
908943fi
909944if [ " $need_disk_limit " = " y" ] || [ " $need_disk_limit " = " Y" ]; then
910945 echo " true" > /usr/local/bin/docker_need_disk_limit
911- while true ; do
912- _green " How large a Docker storage pool is needed? (unit: GB, e.g., enter 20 for 20G):"
913- reading " 需要多大的Docker存储池?(单位GB,例如输入20表示20G):" docker_pool_size
914- if [[ " $docker_pool_size " =~ ^[1-9][0-9]* $ ]]; then
915- break
916- else
917- _yellow " Invalid input, please enter a positive integer."
918- _yellow " 输入无效,请输入一个正整数。"
919- fi
920- done
946+ if [[ -n " ${DOCKER_POOL_SIZE} " ]] && [[ " ${DOCKER_POOL_SIZE} " =~ ^[1-9][0-9]* $ ]]; then
947+ _yellow " DOCKER_POOL_SIZE=${DOCKER_POOL_SIZE} detected, skipping prompt"
948+ docker_pool_size=" ${DOCKER_POOL_SIZE} "
949+ else
950+ while true ; do
951+ _green " How large a Docker storage pool is needed? (unit: GB, e.g., enter 20 for 20G):"
952+ reading " 需要多大的Docker存储池?(单位GB,例如输入20表示20G):" docker_pool_size
953+ if [[ " $docker_pool_size " =~ ^[1-9][0-9]* $ ]]; then
954+ break
955+ else
956+ _yellow " Invalid input, please enter a positive integer."
957+ _yellow " 输入无效,请输入一个正整数。"
958+ fi
959+ done
960+ fi
921961 _green " Where do you want to store the Docker loop file? (Enter to default: /opt/docker-pool.img):"
922- reading " Docker循环文件存储位置?(回车则默认:/opt/docker-pool.img):" docker_loop_file
962+ if [[ -n " ${DOCKER_LOOP_FILE} " ]]; then
963+ _yellow " DOCKER_LOOP_FILE=${DOCKER_LOOP_FILE} detected, skipping prompt"
964+ docker_loop_file=" ${DOCKER_LOOP_FILE} "
965+ else
966+ reading " Docker循环文件存储位置?(回车则默认:/opt/docker-pool.img):" docker_loop_file
967+ fi
923968 if [ -z " $docker_loop_file " ]; then
924969 docker_loop_file=" /opt/docker-pool.img"
925970 fi
0 commit comments