|
@ -1,23 +1,32 @@ |
|
|
#!/bin/bash |
|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
need_restart= |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
just_installed= |
|
|
if ! type -p docker; then |
|
|
if ! type -p docker; then |
|
|
echo "Installing docker..." |
|
|
echo "Installing docker..." |
|
|
type -p curl >dev/null || |
|
|
type -p curl >dev/null || |
|
|
apt-get install -y curl </dev/null |
|
|
apt-get install -y curl </dev/null |
|
|
|
|
|
|
|
|
curl -sSL https://get.docker.io | sh |
|
|
|
|
|
|
|
|
curl -sSL https://get.docker.io | sh || exit 1 |
|
|
|
|
|
just_installed=1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
docker_version=17 |
|
|
|
|
|
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)" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$just_installed" ]; then |
|
|
|
|
|
need_restart= |
|
|
|
|
|
docker_version=17 |
|
|
|
|
|
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)" |
|
|
## DOWNGRADE to 17.xx because 18.xx do not support registry v1 |
|
|
## DOWNGRADE to 17.xx because 18.xx do not support registry v1 |
|
|
apt-get install -y --force-yes docker-ce="$version" |
|
|
apt-get install -y --force-yes docker-ce="$version" |
|
|
need_restart=true |
|
|
need_restart=true |
|
|
fi |
|
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if [ "$need_restart" ]; then |
|
|
|
|
|
|
|
|
if [ "$need_restart" ]; then |
|
|
systemctl daemon-reload && |
|
|
systemctl daemon-reload && |
|
|
service docker restart |
|
|
service docker restart |
|
|
|
|
|
fi |
|
|
fi |
|
|
fi |