You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
1.2 KiB

#!/bin/bash
just_installed=
if ! type -p docker; then
echo "Installing docker..."
type -p curl >/dev/null ||
apt-get install -y curl </dev/null
curl -sSL https://get.docker.io | sh || exit 1
just_installed=1
fi
if [ -n "$just_installed" ]; then
need_restart=
case $(lsb_release -is) in
Debian)
case $(lsb_release -rs) in
10) docker_version=20.10;;
*) docker_version=17;;
esac
;;
Ubuntu)
case $(lsb_release -rs) in
22.04) docker_version=20.10;;
*) docker_version=17;;
esac
;;
*) docker_version=17;;
esac
if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then
version="$(apt-cache madison docker-ce |
cut -f 2 -d \| |
grep "$docker_version" |
head -n 1 | xargs echo)"
apt-get install -y --allow-downgrades docker-ce="$version"
need_restart=true
fi
if [ -n "$need_restart" ] && [ -z "$NO_DOCKER_RESTART" ]; then
systemctl daemon-reload &&
service docker restart
fi
fi