2019-10-21 23:49:33 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
###
|
|
|
|
# Script Name: install-containerd-helpers
|
|
|
|
#
|
|
|
|
# Description: A library that containers helpers to install containerd on different
|
|
|
|
# distributions based on a package manager
|
|
|
|
###
|
|
|
|
set -x extglob
|
|
|
|
|
|
|
|
# Steps taken from: https://docs.docker.com/install/linux/docker-ce/centos/
|
|
|
|
function install_rpm_containerd() {
|
2020-05-14 17:31:30 +03:00
|
|
|
if [ "${PACKAGE_REPO}" = "stage" ]; then
|
|
|
|
REPO_URL="https://download-stage.docker.com/linux/${DIST_ID}/docker-ce-staging.repo"
|
|
|
|
else
|
|
|
|
REPO_URL="https://download.docker.com/linux/${DIST_ID}/docker-ce.repo"
|
|
|
|
fi
|
|
|
|
|
2020-02-20 14:54:40 +03:00
|
|
|
# Install containerd dependency for non-zypper dependecies
|
2020-05-14 17:31:30 +03:00
|
|
|
echo "[DEBUG] Installing engine dependencies from ${REPO_URL}"
|
2020-02-20 15:05:26 +03:00
|
|
|
|
2020-10-23 00:06:11 +03:00
|
|
|
# Note: we enable test channel to be able to test non-stable containerd packages as well.
|
|
|
|
# Once a containerd package becomes stable it will also be available in the test channel,
|
|
|
|
# so this logic works for both cases.
|
|
|
|
# (See also same logic in install_debian_containerd)
|
|
|
|
|
2024-09-04 11:43:17 +03:00
|
|
|
if command -v dnf5; then
|
|
|
|
dnf --version
|
|
|
|
|
2024-09-04 11:46:31 +03:00
|
|
|
# FIXME(thaJeztah); strip empty lines as workaround for https://github.com/rpm-software-management/dnf5/issues/1603
|
|
|
|
TMP_REPO_FILE="$(mktemp --dry-run)"
|
|
|
|
curl -fsSL "${REPO_URL}" | tr -s '\n' > "${TMP_REPO_FILE}"
|
|
|
|
dnf config-manager addrepo --save-filename=docker-ce.repo --overwrite --from-repofile="${TMP_REPO_FILE}"
|
|
|
|
rm -f "${TMP_REPO_FILE}"
|
|
|
|
# dnf config-manager addrepo --save-filename=docker-ce.repo --from-repofile="${REPO_URL}"
|
2024-09-04 11:43:17 +03:00
|
|
|
dnf config-manager setopt 'docker-ce-*.enabled=0'
|
|
|
|
dnf config-manager setopt 'docker-ce-test.enabled=1'
|
|
|
|
dnf makecache
|
|
|
|
elif command -v dnf; then
|
2024-09-04 11:38:07 +03:00
|
|
|
dnf --version
|
|
|
|
|
2020-10-23 00:06:11 +03:00
|
|
|
dnf config-manager --add-repo "${REPO_URL}"
|
2024-09-04 11:38:07 +03:00
|
|
|
dnf config-manager --set-disabled 'docker-ce-*'
|
|
|
|
dnf config-manager --set-enabled 'docker-ce-test'
|
2020-10-23 00:06:11 +03:00
|
|
|
dnf makecache
|
|
|
|
else
|
|
|
|
yum-config-manager --add-repo "${REPO_URL}"
|
2024-09-04 11:38:07 +03:00
|
|
|
yum-config-manager --disable 'docker-ce-*'
|
|
|
|
yum-config-manager --enable 'docker-ce-test'
|
2020-10-23 00:06:11 +03:00
|
|
|
yum makecache
|
2020-02-20 15:05:26 +03:00
|
|
|
fi
|
2019-10-21 23:49:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Steps taken from: https://docs.docker.com/install/linux/docker-ce/ubuntu/
|
|
|
|
function install_debian_containerd() {
|
2020-05-14 17:31:30 +03:00
|
|
|
if [ "${PACKAGE_REPO}" = "stage" ]; then
|
|
|
|
REPO_URL="https://download-stage.docker.com/linux/${DIST_ID}"
|
|
|
|
else
|
|
|
|
REPO_URL="https://download.docker.com/linux/${DIST_ID}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "[DEBUG] Installing engine dependencies from ${REPO_URL}"
|
2020-02-21 15:11:39 +03:00
|
|
|
|
|
|
|
#TODO include this step in the get.docker.com installation script
|
|
|
|
# Make sure ca-certificates are up-to-date
|
|
|
|
update-ca-certificates -f
|
|
|
|
|
2020-05-14 17:31:30 +03:00
|
|
|
curl -fsSL "${REPO_URL}/gpg" | apt-key add -
|
2019-10-21 23:49:33 +03:00
|
|
|
|
2021-04-07 11:46:21 +03:00
|
|
|
if [ "${DIST_VERSION}" = "sid" ]; then
|
|
|
|
echo 'Debian sid ("unstable") cannot be used for packaging: replace with the actual codename'
|
|
|
|
exit 1
|
2020-02-20 14:54:40 +03:00
|
|
|
fi
|
2020-02-20 15:05:26 +03:00
|
|
|
ARCH=$(dpkg --print-architecture)
|
2020-10-23 00:06:11 +03:00
|
|
|
|
|
|
|
# Note: we enable test channel to be able to test non-stable containerd packages as well.
|
|
|
|
# Once a containerd package becomes stable it will also be available in the test channel,
|
|
|
|
# so this logic works for both cases.
|
|
|
|
# (See also same logic in install_rpm_containerd)
|
|
|
|
echo "deb [arch=${ARCH}] ${REPO_URL} ${DIST_VERSION} test" > /etc/apt/sources.list.d/docker.list
|
2019-10-21 23:49:33 +03:00
|
|
|
|
2020-02-20 14:54:40 +03:00
|
|
|
apt-get update
|
|
|
|
}
|