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.

31 lines
877 B

  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. docker_version=17
  13. if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then
  14. version="$(apt-cache madison docker-ce |
  15. cut -f 2 -d \| |
  16. grep "$docker_version" |
  17. head -n 1 | xargs echo)"
  18. ## DOWNGRADE to 17.xx because 18.xx do not support registry v1
  19. apt-get install -y docker-ce="$version"
  20. need_restart=true
  21. fi
  22. if [ -n "$need_restart" ] && [ -z "$NO_DOCKER_RESTART" ]; then
  23. systemctl daemon-reload &&
  24. service docker restart
  25. fi
  26. fi