mirror of
https://gitee.com/SuperManito/LinuxMirrors
synced 2025-11-03 16:00:26 +08:00
2.3 KiB
2.3 KiB
# !/bin/bash
function install_docker() {
local region_code="$(curl -s ipinfo.io/country)"
local close_firewall="true" # close firewalld service and selinux (redhat systems need)
local source_docker_ce_address="mirrors.tencent.com/docker-ce" # global high availability address
local source_docker_ce_protocol="https"
local source_docker_registry_address=""
# judge network environment
if [[ "${region_code}" == "CN" ]]; then
local source_intranet_address=""
# use intranet source if possible
if [ -s "/sys/class/dmi/id/sys_vendor" ]; then
local sys_vendor="$(cat /sys/class/dmi/id/sys_vendor)"
if [[ "${sys_vendor}" == *"Alibaba"* ]]; then
source_intranet_address="mirrors.cloud.aliyuncs.com/docker-ce"
elif [[ "${sys_vendor}" == *"Huawei"* ]]; then
source_intranet_address="mirrors.myhuaweicloud.com/docker-ce"
elif [[ "${sys_vendor}" == *"Tencent"* ]]; then
source_intranet_address="mirrors.tencentyun.com/docker-ce"
elif [[ "${sys_vendor}" == *"Inspur"* ]]; then
source_intranet_address="mirrors.ivolces.com/docker-ce"
fi
else
cat /etc/motd | grep "Alibaba Cloud " -q
if [ $? -eq 0 ]; then
source_intranet_address="mirrors.cloud.aliyuncs.com/docker-ce"
fi
fi
# check connectivity
if [ -n "${source_intranet_address}" ]; then
if ping -c1 -W1 "${source_intranet_address%%/*}" >/dev/null 2>&1; then
source_docker_ce_address="${source_intranet_address}"
source_docker_ce_protocol="http"
fi
fi
source_docker_registry_address="docker.1ms.run"
else
source_docker_ce_address="download.docker.com"
source_docker_registry_address="registry.hub.docker.com"
fi
# run
bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \
--source "${source_docker_ce_address}" \
--source-registry "${source_docker_registry_address}" \
--protocol "${source_docker_ce_protocol}" \
--close-firewall "${close_firewall}" \
--install-latest true \
--ignore-backup-tips \
--pure-mode
}
install_docker