#!/usr/bin/env bash # # Mirantis Container Runtime installer # # Script build information: # COMMIT_SHA=88a88bba0506b396a486c7f81412481489646233 # COMMIT_SHA_PVAL=88a88bb # SEMVER_VERSION=1.0.24 # PUBLISH_STRING=stable # ENV VARIABLES: # Essential: # - DOCKER_URL - URL to package repo # - CHANNEL - channel in the package repo # - VERSION - MCR release version # Optional: # - CONTAINERD_VERSION- Containerd package version # Development: # - DRY_RUN - installation will be with dry-run flag # - SKIP_REPO_SETUP - the current configured repos will be only used # DOCKER_URL and CHANNEL will be ignored # set -e MCR_MAIN_VERSION="" DIST_ID="" CHANNEL=${CHANNEL:-test} DOCKER_PACKAGE_NAME="docker-ee" CONTAINERD_PACKAGE_NAME="containerd.io" MIN_ROOTLESS_VER="20.10.12" MIN_MCR_WITH_C8D_VER="23.0.1" SH_C='sh -c' # Parse an MCR product version string. # # If the version is well-formed, this function exits with a success status # and the parsed components of the version are placed into $BASH_REMATCH. # # ${BASH_REMATCH[1]} - the MAJOR.MINOR.PATCH # ${BASH_REMATCH[3]} - the tp or rc designator # ${BASH_REMATCH[4]} - the pre-release increment or hotfix number # # Consider the following versions that we might support: # 23.0.12 - A version by itself. Install latest release build. # 23.0.12-0 - A specific build version. We use these, for example, if the # 23.0.12-1 we need to rebuild with a new fipster. # 23.0.13-tp1 - A specific tp version # 23.0.13-tp2 # 23.0.13-rc1 - A specific rc version # 23.0.13-rc2 # # There is no "build version" for pre-releases, so 23.0.13-2-tp1 is not valid. function mcr_ver() { [[ $1 =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-([1-9][0-9]*))?(-(tp|rc)([1-9][0-9]*))?$ ]] } get_dep_package_version_deb(){ local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" local dep_package="${3:?Please specify dependance package name}" ${SH_C} "apt-cache show ${package}=${version} \ | grep -oP '${dep_package} \(\K[^\)]+' \ | awk '{print \$2}'" } get_dep_package_version_yum(){ local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" local dep_package="${3:?Please specify dependance package name}" ${SH_C} "yum deplist ""${package}""-""${version}"" \ | awk '\$1 == \"dependency:\" && \$2 == \"${dep_package}\" {print \$4}'" } get_dep_package_version_zypper(){ local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" local dep_package="${3:?Please specify dependance package name}" full_package_version="$(get_full_package_version_zypper "${package}" "${version}")" # download the rpm file and find out the dependency ${SH_C} "zypper install --force --download-only --no-confirm ""${package}""-""${full_package_version}"" &> /dev/null" file_package_version="${full_package_version##*:}" find /var/cache/zypp/packages/ -name "${package}-${file_package_version}*.rpm" -exec rpm -qR -p {} \; \ | awk '$1 == "'"${dep_package}"'" {print $3}' } get_dep_package_version(){ local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" local dep_package="${3:?Please specify dependance package name}" case "${DIST_ID}" in ubuntu) get_dep_package_version_deb "${package}" "${version}" "${dep_package}" ;; centos | rhel | rocky | amzn | ol) get_dep_package_version_yum "${package}" "${version}" "${dep_package}" ;; sles | opensuse-leap) get_dep_package_version_zypper "${package}" "${version}" "${dep_package}" ;; esac } TAKE_HIGHEST_VERSION="sort -u | head -n1" STRIP_EPOCH="sed 's/^[[:digit:]]\+\://'" get_full_package_version_deb () { local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" ${SH_C} "apt-cache madison ${package} \ | awk 'index(\$1, \"${package}\") && index(\$2, \"${version}\") {print \$2}' FS='[[:space:]]+\\\\|[[:space:]]+' \ | ${TAKE_HIGHEST_VERSION}" } get_full_package_version_yum () { local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" ${SH_C} "yum list --showduplicates ${package} \ | awk 'index(\$1, \"${package}\") && index(\$2, \"${version}\") {print \$2}' FS='[[:space:]]+' \ | ${TAKE_HIGHEST_VERSION} \ | ${STRIP_EPOCH}" } get_full_package_version_zypper () { local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" ${SH_C} "zypper search --match-exact --details ${package} \ | awk '\$3 == \"package\" && index(\$4, \"${version}\") {print \$4}' FS='[[:space:]]+\\\\|[[:space:]]+' \ | ${TAKE_HIGHEST_VERSION}" } get_full_package_version() { local package="${1:?Please specify package name}" local version="${2:?Please specify package version}" case "${DIST_ID}" in ubuntu) get_full_package_version_deb "${package}" "${version}" ;; centos | rhel | rocky | amzn | ol) get_full_package_version_yum "${package}" "${version}" ;; sles | opensuse-leap) get_full_package_version_zypper "${package}" "${version}" ;; esac } get_docker_c8d_dep() { local version=${1:?"Please specify docker version"} local c8d_dep c8d_dep="$(get_dep_package_version "${DOCKER_PACKAGE_NAME}" "${version}" "${CONTAINERD_PACKAGE_NAME}")" get_full_package_version "${CONTAINERD_PACKAGE_NAME}" "${c8d_dep}" } get_c8d_mapped_version() { local mcr_ver=${1:-MCR_MAIN_VERSION} local c8d_ver declare -rA mcr_c8d_deb_map=( ["23.0.1"]="1.6.17" ["23.0.3"]="1.6.19" ["23.0.5"]="1.6.20" ["23.0.6"]="1.6.21" ["23.0.7"]="1.6.22" ["23.0.8"]="1.6.25~rc.1-1" ["23.0.9"]="1.6.28~rc.1-1" ["23.0.9-1"]="1.6.28~rc.1-2" ['23.0.10']="1.6.30~rc.2-1" ['23.0.13']="1.6.32" ['23.0.14']="1.6.33" ) declare -rA mcr_c8d_rpm_map=( ["23.0.1"]="1.6.17" ["23.0.3"]="1.6.19" ["23.0.5"]="1.6.20" ["23.0.6"]="1.6.21" ["23.0.7"]="1.6.22" ["23.0.8"]="1.6.25-2.1.rc.1.1" ["23.0.9"]="1.6.28-2.1.rc.1.1" ["23.0.9-1"]="1.6.28-3.1.rc.1.1" ["23.0.10"]="1.6.30-2.2.rc.2.1" ['23.0.13']="1.6.32" ['23.0.14']="1.6.33" ) case "${DIST_ID}" in ubuntu) c8d_ver="${mcr_c8d_deb_map["${mcr_ver}"]}" ;; centos | rhel | rocky | amzn | ol | sles | opensuse-leap) c8d_ver="${mcr_c8d_rpm_map["${mcr_ver}"]}" ;; esac if [ -z "${c8d_ver}" ]; then return 1 fi echo "${c8d_ver}" } get_docker_mapped_version() { local mcr_version="${1:-MCR_MAIN_VERSION}" declare -rA mcr_docker_deb_map=( ["23.0.9"]="23.0.9~3-" ["23.0.9-1"]="23.0.9~4" ) declare -rA mcr_docker_rpm_map=( ["23.0.9"]="23.0.9-3" ["23.0.9-1"]="23.0.9-4" ) local docker_ver case "$DIST_ID" in ubuntu) docker_ver=${mcr_docker_deb_map[${mcr_version}]} if [ -n "${docker_ver}" ]; then echo "${docker_ver}" return 0 fi ;; centos | rhel | rocky | amzn | ol | sles | opensuse-leap) docker_ver=${mcr_docker_rpm_map[${mcr_version}]} if [ -n "${docker_ver}" ]; then echo "${docker_ver}" return 0 fi ;; esac } get_docker_package_version() { local mcr_version="${1:-MCR_MAIN_VERSION}" mcr_ver "${mcr_version}" local main_version=${BASH_REMATCH[1]} local prerelease_designator=${BASH_REMATCH[5]} local build_version=${BASH_REMATCH[6]} local prerelease="${prerelease_designator}${build_version}" ver="$(get_docker_mapped_version "${mcr_version}")" if [ -n "${ver}" ]; then echo "${ver}" return 0 fi case "${DIST_ID}" in ubuntu) # the first number after the tilde corresponds to the prerelease # designator. for tp, it's 0, for rc, it's 2, and for release, it's 3. # build_version does not appear in prerelease versions, we ignore it. case "${prerelease_designator}" in tp) echo "${main_version}~0.${build_version}.${prerelease}" ;; rc) echo "${main_version}~2.${build_version}.${prerelease}" ;; *) echo "${main_version}~$(( 3 + build_version ))" ;; esac ;; centos | rhel | rocky | amzn | ol) case "${prerelease_designator}" in tp) echo "${main_version}-0.${build_version}.${prerelease}." ;; rc) echo "${main_version}-2.${build_version}.${prerelease}." ;; *) echo "${main_version}-$(( 3 + build_version ))." ;; esac ;; sles | opensuse-leap) # On zypper-based systems version terminates before any extra fluffy # bits, which means we can't end our search string (the thing we're # making here) with a dot. This means that, on zipper, we might match # both build version 29 (which ends in -30) and build version 0 (which # ends in -3). If we ever have 30 build versions, we can fix this. case "${prerelease_designator}" in tp) echo "${main_version}-0.${build_version}.${prerelease}" ;; rc) echo "${main_version}-2.${build_version}.${prerelease}" ;; *) echo "${main_version}-$(( 3 + build_version ))" ;; esac ;; esac } get_c8d_version() { local mcr_ver=${1:?Please specify MCR package version} local docker_ver=${2:?Please specify docker package version} if [ -n "${CONTAINERD_VERSION}" ]; then echo "${CONTAINERD_VERSION}" return 0 fi get_c8d_mapped_version "${mcr_ver}" || get_docker_c8d_dep "${docker_ver}" } get_c8d_package_version() { local mcr_ver=${1:?Please specify MCR package version} local docker_ver=${2:?Please specify docker package version} get_full_package_version "${CONTAINERD_PACKAGE_NAME}" "$(get_c8d_version "${mcr_ver}" "${docker_ver}")" } command_exists() { command -v "$@" > /dev/null 2>&1 } on_ec2() { [ -f /sys/hypervisor/uuid ] && [ "$(head -c 3 /sys/hypervisor/uuid)" == ec2 ] } strip_trailing_slash() { echo "${1/%\/}" } # version_gte checks if the version specified in $VERSION is at least # the given CalVer (YY.MM) version. returns 0 (success) if $VERSION is either # unset (=latest) or newer or equal than the specified version. Returns 1 (fail) # otherwise. # # examples: # # VERSION=20.10 # version_gte 20.10 // 0 (success) # version_gte 19.03 // 0 (success) # version_gte 21.10 // 1 (fail) version_gte() { if [ -z "$VERSION" ]; then return 0 fi calver_compare "${VERSION%%-*}" "$1" } # calver_compare compares two CalVer (YY.MM.VER) version strings. returns 0 (success) # if version A is newer or equal than version B, or 1 (fail) otherwise. Patch # releases and pre-release (-alpha/-beta) are not taken into account # # examples: # # calver_compare 20.10.12 19.03 // 0 (success) # calver_compare 20.10.12 20.10.12 // 0 (success) # calver_compare 19.03.02 20.10.12 // 1 (fail) calver_compare() ( set +x yy_a="$(echo "$1" | cut -d'.' -f1)" yy_b="$(echo "$2" | cut -d'.' -f1)" if (( "$yy_a" < "$yy_b" )); then return 1 fi if (( "$yy_a" > "$yy_b" )); then return 0 fi mm_a="$(echo "$1" | cut -d'.' -f2)" mm_b="$(echo "$2" | cut -d'.' -f2)" if (( "${mm_a}" < "${mm_b}" )); then return 1 fi ver_a="$(echo "$1" | cut -d'.' -f3)" ver_b="$(echo "$2" | cut -d'.' -f3)" if (( "$ver_a" < "$ver_b" )); then return 1 fi return 0 ) ubuntu_prepare() { export DEBIAN_FRONTEND=noninteractive local pre_reqs="apt-transport-https ca-certificates curl software-properties-common" if ! command -v gpg > /dev/null; then pre_reqs="$pre_reqs gnupg" fi ( set -ex ${SH_C} "apt-get update -qq" ${SH_C} "apt-get install -y -qq $pre_reqs >/dev/null" ) local ubuntu_url ubuntu_url=$(strip_trailing_slash "${DOCKER_URL}") # Check if we have a gpg (should be valid repo to use if it's there) before appending suffix if ! curl -fsSL "${ubuntu_url}/gpg" >/dev/null; then # URL's may not be suffixed with ubuntu, let's make sure that they are if [[ ! "${ubuntu_url}" =~ /ubuntu$ ]]; then ubuntu_url="${ubuntu_url}/ubuntu" fi fi local arch arch="$(dpkg --print-architecture)" # Grab this outside of the command to install, so it's not muddled local release # shellcheck disable=SC1091 release="$(. /etc/os-release && echo "${VERSION_CODENAME}")" ( set -ex ${SH_C} "curl -fsSL ${ubuntu_url}/gpg | apt-key add -qq - >/dev/null" ${SH_C} "add-apt-repository -y 'deb [arch=${arch}] ${ubuntu_url} ${release} ${CHANNEL}' >/dev/null" ${SH_C} "apt-get update -qq >/dev/null" ) } ubuntu_install() { local docker_version="${1:?Specify docker version}" local dist_version="${2}" if [[ -z "${SKIP_REPO_SETUP}" ]]; then ubuntu_prepare fi local docker_package="${DOCKER_PACKAGE_NAME}" # By default, don't include a cli_package and rootless_package to install just let the package manager grab the topmost one local cli_package="${DOCKER_PACKAGE_NAME}-cli" local rootless_package="${DOCKER_PACKAGE_NAME}-rootless-extras" local containerd_package="${CONTAINERD_PACKAGE_NAME}" docker_package_version="$(get_full_package_version "${docker_package}" "${docker_version}")" cli_package_version="$(get_full_package_version "${cli_package}" "${docker_version}")" if version_gte "${MIN_ROOTLESS_VER}"; then rootless_package_version="$(get_full_package_version "${rootless_package}" "${docker_version}")" fi echo "INFO: Searching repository for Docker package VERSION '${docker_version}'" if [ -z "${docker_package_version}" ]; then echo echo "ERROR: '${docker_version}' not found amongst apt-cache madison results" echo exit 1 fi # If a cli package was found for the given version then include it in the installation if [ -n "${cli_package_version}" ]; then cli_package+="=${cli_package_version}" fi # If a rootless package was found for the given version then include it in the installation if [ -n "$rootless_package_version" ]; then rootless_package+="=${rootless_package_version}" fi docker_package+="=${docker_package_version}" if version_gte "$MIN_MCR_WITH_C8D_VER"; then c8d_version="$(get_c8d_package_version "${MCR_MAIN_VERSION}" "${docker_package_version}")" if [ -n "${c8d_version}" ]; then containerd_package+="=${c8d_version}" fi fi ( local apt_flags="-y -qq" if [ "$dist_version" != "14.04" ]; then apt_flags+=" --allow-downgrades" fi if [ -n "$DRY_RUN" ]; then apt_flags+=" --dry-run" fi set -ex ${SH_C} "apt-get install ${apt_flags} ${docker_package} ${cli_package} ${rootless_package} ${containerd_package}" ) } yum_prepare() { local dist_id="${1:?Specify Distribution Id}" local dist_version="${2:?Please specify Distribution version}" local yum_url yum_url=$(strip_trailing_slash "${DOCKER_URL}") ( set -ex ${SH_C} "rpm -qa | grep curl || yum install -q -y curl" ) # Check if we have a usable repo file before appending suffix if ! curl -fsSL "${yum_url}/docker-ee.repo" >/dev/null; then if [[ ! "${yum_url}" =~ /centos$|/rhel$|rocky$ ]]; then yum_url="${yum_url}/${dist_id}" fi fi case ${dist_id}:${dist_version} in oraclelinux:7*) # Enable "Oracle Linux 7 Server Add ons (x86_64)" repo for oraclelinux7 ( set -ex ${SH_C} 'yum-config-manager --enable ol7_addons' ) ;; rhel:7*) extras_repo="rhel-7-server-extras-rpms" if on_ec2; then ${SH_C} "yum install -y rh-amazon-rhui-client" extras_repo="rhel-7-server-rhui-extras-rpms" fi # We don't actually make packages for 7.1, but they can still use the 7 repository if [ "${dist_version}" = "7.1" ]; then dist_version="7" fi # Enable extras repo for rhel ( set -ex ${SH_C} "yum-config-manager --enable ${extras_repo}" ) ;; esac ( set -ex ${SH_C} "echo '${yum_url}' > /etc/yum/vars/dockerurl" ${SH_C} "echo '${dist_version}' > /etc/yum/vars/dockerosversion" ${SH_C} "yum install -q -y yum-utils device-mapper-persistent-data lvm2" ${SH_C} "yum-config-manager --add-repo ${yum_url}/docker-ee.repo" ${SH_C} "yum-config-manager --disable 'docker-ee-*'" ${SH_C} "yum-config-manager --enable 'docker-ee-${CHANNEL}'" ) } yum_install() { local docker_version="${1:?Specify docker version}" local dist_id="${2:?Specify Distribution Id}" local dist_version="${3:?Please specify Distribution version}" if [[ -z "${SKIP_REPO_SETUP}" ]]; then yum_prepare "${dist_id}" "${dist_version}" fi local docker_package="${DOCKER_PACKAGE_NAME}" # By default, don't include a cli_package and rootless_package to install just let the package manager grab the topmost one local cli_package="${DOCKER_PACKAGE_NAME}-cli" local rootless_package="" local containerd_package="${CONTAINERD_PACKAGE_NAME}" local yum_cmd="install" docker_package_version="$(get_full_package_version "${docker_package}" "${docker_version}")" cli_package_version="$(get_full_package_version "${cli_package}" "${docker_version}")" if version_gte "$MIN_ROOTLESS_VER" && [ "${dist_id}:${dist_version}" != "oraclelinux:7" ]; then # like the CLI, rootless-extras packages don't start with 3:. They don't # start with anything, actually. rootless_package="${DOCKER_PACKAGE_NAME}-rootless-extras" rootless_package_version="$(get_full_package_version "${rootless_package}" "${docker_version}")" fi echo "INFO: Searching repository for Docker package VERSION '${docker_version}'" if [ -z "${docker_package_version}" ]; then echo echo "ERROR: '${docker_version}' not found amongst yum list results" echo exit 1 fi if [ -n "$cli_package_version" ]; then cli_package+="-${cli_package_version}" fi if [ -n "$rootless_package_version" ]; then rootless_package+="-${rootless_package_version}" fi docker_package+="-${docker_package_version}" # Check if we're doing an upgrade / downgrade and the command accordingly echo "INFO: Checking to determine whether this should be an upgrade or downgrade" # If the package isn't realdy installed then don't try upgrade / downgrade if ! ${SH_C} "yum list installed ${DOCKER_PACKAGE_NAME}" >/dev/null; then yum_cmd="install" # Exit codes when using --assumeno will give 0 if there would be an upgrade/downgrade, 1 if there is elif ! ${SH_C} "yum upgrade --assumeno ${docker_package}"; then yum_cmd="upgrade" elif ! ${SH_C} "yum downgrade --assumeno ${docker_package}"; then yum_cmd="downgrade" fi echo "INFO: will use install command $yum_cmd" if version_gte "$MIN_MCR_WITH_C8D_VER"; then c8d_version="$(get_c8d_package_version "${MCR_MAIN_VERSION}" "${docker_package_version}")" if [ -n "${c8d_version}" ]; then containerd_package+="-${c8d_version}" fi fi ( local yum_flags="-q" if [ -n "${DRY_RUN}" ]; then yum_flags+=" --assumeno" else yum_flags+=" --assumeyes" fi set -ex ${SH_C} "yum ${yum_cmd} ${yum_flags} ${docker_package} ${cli_package} ${rootless_package} ${containerd_package}" ) } REPO_VERSION="" zypper_prepare() { local arch arch="$(uname -m)" ( set -ex $SH_C "zypper install --no-confirm curl gawk" ) local zypper_url zypper_url=$(strip_trailing_slash "${DOCKER_URL}") # No need to append sles if we already have a valid repo if ! curl -fsL "${zypper_url}/docker-ee.repo" >/dev/null; then zypper_url="${zypper_url}/sles" fi ( set -ex # SLES images have installed Docker CE by default, which conflicts w/ MCR, so it needs to be deleted ${SH_C} "zypper remove -y docker docker-engine docker-libnetwork runc containerd || true" ${SH_C} "zypper removerepo docker-ee-${CHANNEL}" # this will always return 0 even if repo alias not found ${SH_C} "zypper addrepo ${zypper_url}/${REPO_VERSION}/${arch}/${CHANNEL} docker-ee-${CHANNEL}" ${SH_C} "rpm --import '${zypper_url}/gpg'" ${SH_C} "zypper refresh" ) } zypper_install() { local docker_version="${1:?Specify docker version}" local dist_version="${2}" case "${dist_version}" in 12*) REPO_VERSION=12.3 ;; 15*) REPO_VERSION=15 ;; esac if [[ -z "${SKIP_REPO_SETUP}" ]]; then zypper_prepare fi local docker_package="${DOCKER_PACKAGE_NAME}" # By default, don't include a cli_package and rootless_package to install just let the package manager grab the topmost one local cli_package="${DOCKER_PACKAGE_NAME}-cli" local rootless_package="" local containerd_package="${CONTAINERD_PACKAGE_NAME}" docker_package_version="$(get_full_package_version "${docker_package}" "${docker_version}")" cli_package_version="$(get_full_package_version "${cli_package}" "${docker_version}")" if version_gte "${MIN_ROOTLESS_VER}" && [ "${REPO_VERSION}" != "12.3" ]; then rootless_package="${DOCKER_PACKAGE_NAME}-rootless-extras" rootless_package_version="$(get_full_package_version "${rootless_package}" "${docker_version}")" fi echo "INFO: Searching repository for VERSION '${docker_version}'" if [ -z "${docker_package_version}" ]; then echo echo "ERROR: '${docker_version}' not found amongst zypper search results" echo exit 1 fi # If a cli package was found for the given version then include it in the installation if [ -n "${cli_package_version}" ]; then cli_package+="-${cli_package_version}" fi # If a rootless package was found for the given version then include it in the installation if [ -n "${rootless_package_version}" ]; then rootless_package+="-${rootless_package_version}" fi docker_package+="-${docker_package_version}" if version_gte "$MIN_MCR_WITH_C8D_VER"; then c8d_version="$(get_c8d_package_version "${MCR_MAIN_VERSION}" "${docker_package_version}")" if [ -n "${c8d_version}" ]; then containerd_package+="-${c8d_version}" fi fi ( local zypper_flags="--replacefiles --force --no-confirm" if [ -n "${DRY_RUN}" ]; then zypper_flags+=" --dry-run" fi if [[ "${dist_version}" == 15* ]]; then zypper_flags+=" --allow-vendor-change" fi set -ex ${SH_C} "zypper install ${zypper_flags} ${docker_package} ${cli_package} ${rootless_package} ${containerd_package}" ) } main() { user="$(id -un 2>/dev/null || true)" if [ "${user}" != 'root' ]; then if command_exists sudo; then SH_C='sudo -E sh -c' elif command_exists su; then SH_C='su -c' else cat >&2 <<-'EOF' Error: this installer needs the ability to run commands as root. We are unable to find either "sudo" or "su" available to make this happen. EOF exit 1 fi fi # shellcheck disable=SC1091 DIST_ID="$(. /etc/os-release && echo "$ID")" # shellcheck disable=SC1091 dist_version="$(. /etc/os-release && echo "$VERSION_ID")" if [ -z "${DOCKER_URL}" ]; then echo "ERROR: DOCKER_URL must be set, exiting..." exit 1 fi if ! mcr_ver "${VERSION}"; then echo "${VERSION} doesn't match with expected pattern. Version must follow this pattern a.b.c, a.b.c-d, a.b.c-(tp|rc)e, a.b.c-d-(tp|rc)e, where a,b,c,d,e are numbers." exit 1 fi MCR_MAIN_VERSION="${BASH_REMATCH[1]}${BASH_REMATCH[2]}" docker_pkg_ver="$(get_docker_package_version "${VERSION}")" case "$DIST_ID:$dist_version" in ubuntu:14.04|ubuntu:16.04|ubuntu:18.04|ubuntu:20.04|ubuntu:22.04) ubuntu_install "${docker_pkg_ver}" "${dist_version}" exit 0 ;; centos:*|rhel:*|rocky:*) # Strip point versions, they don't really matter yum_install "${docker_pkg_ver}" "${DIST_ID}" "${dist_version/\.*/}" exit 0 ;; amzn:2) yum_install "${docker_pkg_ver}" "amazonlinux" 2 exit 0 ;; ol:*) # Consider only major version for OL distros dist_version=${dist_version%%.*} yum_install "${docker_pkg_ver}" "oraclelinux" "${dist_version}" exit 0 ;; sles:12*|sles:15*|opensuse-leap:15*) zypper_install "${docker_pkg_ver}" "${dist_version}" exit 0 ;; *) echo echo "ERROR: Unsupported distribution / distribution version '${DIST_ID}:${dist_version}'" echo " If you feel this is a mistake please contact Mirantis support" echo exit 1 ;; esac } main