Skip to content

Commit

Permalink
update migration tool url (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkLeong authored Jan 5, 2023
1 parent 55b5963 commit 10b0341
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion build/scripts/migration/script.d/01-migrate-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ __is_migration_needed() {

__is_version_gt "${version2}" "${version1}"
}
__get_download_domain(){
local region
# Use ipconfig.io/country and https://ifconfig.io/country_code to get the country code
region=$(curl --connect-timeout 2 -s ipconfig.io/country || echo "")
if [ "${region}" = "" ]; then
region=$(curl --connect-timeout 2 -s https://ifconfig.io/country_code || echo "")
fi
if [[ "${region}" = "China" ]] || [[ "${region}" = "CN" ]]; then
echo "https://casaos.oss-cn-shanghai.aliyuncs.com/"
else
echo "https://github.com/"
fi
}

DOWNLOAD_DOMAIN=$(__get_download_domain)

BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../..

Expand Down Expand Up @@ -162,7 +177,7 @@ pushd "${MIGRATION_SERVICE_DIR}"
continue
fi

MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz
MIGRATION_TOOL_URL=${DOWNLOAD_DOMAIN}IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz
__info "Dowloading ${MIGRATION_TOOL_URL}..."
curl -sL -O "${MIGRATION_TOOL_URL}"
done
Expand Down

0 comments on commit 10b0341

Please sign in to comment.