fork 0k-charms
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.

46 lines
1.2 KiB

  1. #!/bin/bash
  2. just_installed=
  3. if ! type -p docker; then
  4. echo "Installing docker..."
  5. type -p curl >/dev/null ||
  6. apt-get install -y curl </dev/null
  7. curl -sSL https://get.docker.io | sh || exit 1
  8. just_installed=1
  9. fi
  10. if [ -n "$just_installed" ]; then
  11. need_restart=
  12. case $(lsb_release -is) in
  13. Debian)
  14. case $(lsb_release -rs) in
  15. 10) docker_version=20.10;;
  16. *) docker_version=17;;
  17. esac
  18. ;;
  19. Ubuntu)
  20. case $(lsb_release -rs) in
  21. 22.04) docker_version=20.10;;
  22. *) docker_version=17;;
  23. esac
  24. ;;
  25. *) docker_version=17;;
  26. esac
  27. if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then
  28. version="$(apt-cache madison docker-ce |
  29. cut -f 2 -d \| |
  30. grep "$docker_version" |
  31. head -n 1 | xargs echo)"
  32. apt-get install -y --allow-downgrades docker-ce="$version"
  33. need_restart=true
  34. fi
  35. if [ -n "$need_restart" ] && [ -z "$NO_DOCKER_RESTART" ]; then
  36. systemctl daemon-reload &&
  37. service docker restart
  38. fi
  39. fi