diff --git a/scripts/0_prepare.sh b/scripts/0_prepare.sh index 8cadac3a..7e7b2c51 100644 --- a/scripts/0_prepare.sh +++ b/scripts/0_prepare.sh @@ -9,6 +9,7 @@ IMAGE_DIR="${BASE_DIR}/images" function download_and_verify() { local url=$1 local target_path=$2 + local md5_url=$3 local md5_target_path="${target_path}.md5" parent_dir=$(dirname "${target_path}") @@ -19,7 +20,12 @@ function download_and_verify() { prepare_check_required_pkg if [[ ! -f "${md5_target_path}" ]]; then echo "$(gettext 'Starting to download'): ${url}.md5" - wget -q "${url}.md5" -O "${md5_target_path}" || { + + if [[ -z "${md5_url}" ]]; then + md5_url="${url}.md5" + fi + + wget -q "${md5_url}" -O "${md5_target_path}" || { log_error "$(gettext 'Download fails, check the network is normal')" rm -f "${md5_target_path}" exit 1 @@ -43,11 +49,11 @@ function download_and_verify() { } function prepare_docker_bin() { - download_and_verify "${DOCKER_BIN_URL}" "${BASE_DIR}/docker/docker.tar.gz" + download_and_verify "${DOCKER_BIN_URL}" "${BASE_DIR}/docker/docker.tar.gz" "${DOCKER_MD5_URL}" } function prepare_compose_bin() { - download_and_verify "${DOCKER_COMPOSE_BIN_URL}" "${BASE_DIR}/docker/docker-compose" + download_and_verify "${COMPOSE_BIN_URL}" "${BASE_DIR}/docker/docker-compose" "${COMPOSE_MD5_URL}" chown -R root:root "${BASE_DIR}/docker/docker-compose" chmod +x "${BASE_DIR}/docker/docker-compose" } diff --git a/scripts/const.sh b/scripts/const.sh index 793e0b02..044e23b1 100644 --- a/scripts/const.sh +++ b/scripts/const.sh @@ -27,10 +27,19 @@ STATIC_ENV=${PROJECT_DIR}/static.env export OS=$(uname -s) export DOCKER_VERSION=27.1.1 -export DOCKER_MIRROR="https://download.jumpserver.org/docker/docker-ce/linux/static/stable" +DOCKER_URL="https://download.docker.com/linux/static/stable" +DOCKER_MIRROR="https://download.jumpserver.org/docker/docker-ce/linux/static/stable" + +if [[ "${USE_MIRROR}" == "1" ]];then + DOCKER_URL=${DOCKER_MIRROR} +fi export DOCKER_COMPOSE_VERSION=v2.29.1 -export DOCKER_COMPOSE_MIRROR="https://download.jumpserver.org/docker/compose/releases/download" +COMPOSE_URL="https://github.com/docker/compose/releases/download" +COMPOSE_MIRROR="https://download.jumpserver.org/docker/compose/releases/download" +if [[ "${USE_MIRROR}" == "1" ]];then + COMPOSE_URL=${COMPOSE_MIRROR} +fi ARCH=$(uname -m) if [ -n "${BUILD_ARCH}" ]; then @@ -38,5 +47,7 @@ if [ -n "${BUILD_ARCH}" ]; then fi export ARCH -export DOCKER_BIN_URL="${DOCKER_MIRROR}/${ARCH}/docker-${DOCKER_VERSION}.tgz" -export DOCKER_COMPOSE_BIN_URL="${DOCKER_COMPOSE_MIRROR}/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH}" \ No newline at end of file +export DOCKER_BIN_URL="${DOCKER_URL}/${ARCH}/docker-${DOCKER_VERSION}.tgz" +export DOCKER_MD5_URL="${DOCKER_MIRROR}/${ARCH}/docker-${DOCKER_VERSION}.tgz.md5" +export COMPOSE_BIN_URL="${COMPOSE_URL}/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH}" +export COMPOSE_MD5_URL="${COMPOSE_MIRROR}/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH}.md5"