Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pm to install docker #1321

Merged
merged 22 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scripts/docker_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ docker_compose() {
info "Compose will not be run."
return 1
fi
run_script 'install_docker'
run_script 'require_docker'
cd "${SCRIPTPATH}/compose/" || fatal "Failed to change directory.\nFailing command: ${F[C]}cd \"${SCRIPTPATH}/compose/\""
run_script 'run_compose' "${COMPOSECOMMAND}"
cd "${SCRIPTPATH}" || fatal "Failed to change directory.\nFailing command: ${F[C]}cd \"${SCRIPTPATH}\""
Expand Down
2 changes: 1 addition & 1 deletion .scripts/enable_docker_systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ enable_docker_systemd() {
}

test_enable_docker_systemd() {
run_script 'install_docker'
run_script 'require_docker'
run_script 'enable_docker_systemd'
}
25 changes: 25 additions & 0 deletions .scripts/get_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'

get_docker() {
# https://github.com/docker/docker-install
notice "Installing docker. Please be patient, this can take a while."
local MKTEMP_GET_DOCKER
MKTEMP_GET_DOCKER=$(mktemp) || fatal "Failed to create temporary docker install script.\nFailing command: ${F[C]}mktemp"
info "Downloading docker install script."
curl -fsSL https://get.docker.com -o "${MKTEMP_GET_DOCKER}" > /dev/null 2>&1 || fatal "Failed to get docker install script.\nFailing command: ${F[C]}curl -fsSL https://get.docker.com -o \"${MKTEMP_GET_DOCKER}\""
info "Running docker install script."
local REDIRECT="> /dev/null 2>&1"
if [[ -n ${VERBOSE:-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then
REDIRECT=""
fi
eval sh "${MKTEMP_GET_DOCKER}" "${REDIRECT}" || fatal "Failed to install docker.\nFailing command: ${F[C]}sh \"${MKTEMP_GET_DOCKER}\" \"${REDIRECT}\""
rm -f "${MKTEMP_GET_DOCKER}" || warn "Failed to remove temporary docker install script."
}

test_get_docker() {
run_script 'remove_snap_docker'
run_script 'get_docker'
docker --version || fatal "Failed to determine docker version.\nFailing command: ${F[C]}docker --version"
}
57 changes: 0 additions & 57 deletions .scripts/install_docker.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .scripts/package_manager_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ package_manager_run() {
run_script "pm_apt_${ACTION}"
elif [[ -n "$(command -v dnf)" ]]; then
run_script "pm_dnf_${ACTION}"
elif [[ -n "$(command -v yum)" ]]; then
run_script "pm_yum_${ACTION}"
elif [[ -n "$(command -v pacman)" ]]; then
run_script "pm_pacman_${ACTION}"
elif [[ -n "$(command -v yum)" ]]; then
run_script "pm_yum_${ACTION}"
else
fatal "Supported package manager not detected!"
fi
Expand Down
8 changes: 6 additions & 2 deletions .scripts/pm_apt_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ set -Eeuo pipefail
IFS=$'\n\t'

pm_apt_install() {
info "Installing dependencies."
apt-get -y install apt-transport-https curl git grep sed whiptail > /dev/null 2>&1 || fatal "Failed to install dependencies from apt.\nFailing command: ${F[C]}apt-get -y install apt-transport-https curl git grep sed whiptail"
notice "Installing dependencies. Please be patient, this can take a while."
local REDIRECT="> /dev/null 2>&1"
if [[ -n ${VERBOSE:-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then
REDIRECT=""
fi
eval apt-get -y install curl git grep sed whiptail "${REDIRECT}" || fatal "Failed to install dependencies from apt.\nFailing command: ${F[C]}apt-get -y install curl git grep sed whiptail"
}

test_pm_apt_install() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail
IFS=$'\n\t'

pm_apt_remove_docker() {
pm_apt_install_docker() {
# https://docs.docker.com/install/linux/docker-ce/debian/
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
info "Removing conflicting Docker packages."
Expand All @@ -12,8 +12,11 @@ pm_apt_remove_docker() {
docker-engine \
docker.io \
runc > /dev/null 2>&1 || true
run_script 'remove_snap_docker'
run_script 'get_docker'
}

test_pm_apt_remove_docker() {
run_script 'pm_apt_remove_docker'
test_pm_apt_install_docker() {
run_script 'pm_apt_repos'
run_script 'pm_apt_install_docker'
}
11 changes: 10 additions & 1 deletion .scripts/pm_apt_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ set -Eeuo pipefail
IFS=$'\n\t'

pm_apt_repos() {
local MINIMUM_APT_TRANSPORT_HTTPS="1"
local INSTALLED_APT_TRANSPORT_HTTPS
INSTALLED_APT_TRANSPORT_HTTPS=$(apt-cache policy apt-transport-https | grep -Po 'Installed: \K.*')
if vergt "${MINIMUM_APT_TRANSPORT_HTTPS}" "${INSTALLED_APT_TRANSPORT_HTTPS}"; then
info "Updating repositories (before installing apt-transport-https)."
apt-get -y update > /dev/null 2>&1 || fatal "Failed to get updates from apt.\nFailing command: ${F[C]}apt-get -y update"
info "Installing APT transport for downloading via the HTTP Secure protocol (HTTPS)."
apt-get -y install apt-transport-https > /dev/null 2>&1 || fatal "Failed to install apt-transport-https from apt.\nFailing command: ${F[C]}apt-get -y install apt-transport-https"
fi
local MINIMUM_LIBSECCOMP2="2.4.4"
# Note compatibility from https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0
local INSTALLED_LIBSECCOMP2
Expand All @@ -16,7 +25,7 @@ pm_apt_repos() {
apt-get -y update > /dev/null 2>&1 || fatal "Failed to get updates from apt.\nFailing command: ${F[C]}apt-get -y update"
if vergt "${MINIMUM_LIBSECCOMP2}" "${INSTALLED_LIBSECCOMP2}"; then
info "Installing libseccomp2 from buster-backports repo."
apt install -t buster-backports libseccomp2 || error "Failed to install libseccomp2 from buster-backports repo."
apt-get -y install -t buster-backports libseccomp2 || fatal "Failed to install libseccomp2 from buster-backports repo."
fi
}

Expand Down
8 changes: 6 additions & 2 deletions .scripts/pm_dnf_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ set -Eeuo pipefail
IFS=$'\n\t'

pm_dnf_install() {
info "Installing dependencies."
dnf -y install curl git grep newt sed > /dev/null 2>&1 || fatal "Failed to install dependencies from dnf.\nFailing command: ${F[C]}dnf -y install curl git grep newt sed"
notice "Installing dependencies. Please be patient, this can take a while."
local REDIRECT="> /dev/null 2>&1"
if [[ -n ${VERBOSE:-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then
REDIRECT=""
fi
eval dnf -y install curl git grep newt sed "${REDIRECT}" || fatal "Failed to install dependencies from dnf.\nFailing command: ${F[C]}dnf -y install curl git grep newt sed"
}

test_pm_dnf_install() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail
IFS=$'\n\t'

pm_dnf_remove_docker() {
pm_dnf_install_docker() {
# https://docs.docker.com/install/linux/docker-ce/fedora/
info "Removing conflicting Docker packages."
dnf -y remove docker \
Expand All @@ -16,9 +16,11 @@ pm_dnf_remove_docker() {
docker-latest-logrotate \
docker-logrotate \
docker-selinux > /dev/null 2>&1 || true
run_script 'remove_snap_docker'
run_script 'get_docker'
}

test_pm_dnf_remove_docker() {
# run_script 'pm_dnf_remove_docker'
warn "CI does not test pm_dnf_remove_docker."
test_pm_dnf_install_docker() {
# run_script 'pm_dnf_install_docker'
warn "CI does not test pm_dnf_install_docker."
}
8 changes: 6 additions & 2 deletions .scripts/pm_pacman_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ set -Eeuo pipefail
IFS=$'\n\t'

pm_pacman_install() {
info "Installing dependencies."
pacman -Sy --noconfirm curl git grep libnewt sed > /dev/null 2>&1 || fatal "Failed to install dependencies using pacman.\nFailing command: ${F[C]}pacman -Sy --noconfirm curl git grep libnewt sed"
notice "Installing dependencies. Please be patient, this can take a while."
local REDIRECT="> /dev/null 2>&1"
if [[ -n ${VERBOSE:-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then
REDIRECT=""
fi
eval pacman -Sy --noconfirm curl git grep libnewt sed "${REDIRECT}" || fatal "Failed to install dependencies using pacman.\nFailing command: ${F[C]}pacman -Sy --noconfirm curl git grep libnewt sed"
}

test_pm_pacman_install() {
Expand Down
17 changes: 17 additions & 0 deletions .scripts/pm_pacman_install_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'

pm_pacman_install_docker() {
notice "Installing docker. Please be patient, this can take a while."
local REDIRECT="> /dev/null 2>&1"
if [[ -n ${VERBOSE:-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then
REDIRECT=""
fi
eval pacman -Sy --noconfirm docker "${REDIRECT}" || fatal "Failed to install docker using pacman.\nFailing command: ${F[C]}pacman -Sy --noconfirm docker"
}

test_pm_pacman_install_docker() {
# run_script 'pm_pacman_install_docker'
warn "CI does not test pm_pacman_install_docker."
}
12 changes: 0 additions & 12 deletions .scripts/pm_pacman_remove_docker.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .scripts/pm_pacman_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -Eeuo pipefail
IFS=$'\n\t'

pm_pacman_repos() {
info "This script does not manage pacman repositories for you. All packages needed should be in the default Arch repos."
info "pacman does not require additional repositories."
}

test_pm_pacman_repos() {
Expand Down
8 changes: 6 additions & 2 deletions .scripts/pm_yum_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ set -Eeuo pipefail
IFS=$'\n\t'

pm_yum_install() {
info "Installing dependencies."
yum -y install curl git grep newt sed > /dev/null 2>&1 || fatal "Failed to install dependencies from yum.\nFailing command: ${F[C]}yum -y install curl git grep newt sed"
notice "Installing dependencies. Please be patient, this can take a while."
local REDIRECT="> /dev/null 2>&1"
if [[ -n ${VERBOSE:-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then
REDIRECT=""
fi
eval yum -y install curl git grep newt sed "${REDIRECT}" || fatal "Failed to install dependencies from yum.\nFailing command: ${F[C]}yum -y install curl git grep newt sed"
}

test_pm_yum_install() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail
IFS=$'\n\t'

pm_yum_remove_docker() {
pm_yum_install_docker() {
# https://docs.docker.com/install/linux/docker-ce/centos/
info "Removing conflicting Docker packages."
yum -y remove docker \
Expand All @@ -14,9 +14,11 @@ pm_yum_remove_docker() {
docker-latest \
docker-latest-logrotate \
docker-logrotate > /dev/null 2>&1 || true
run_script 'remove_snap_docker'
run_script 'get_docker'
}

test_pm_yum_remove_docker() {
# run_script 'pm_yum_remove_docker'
warn "CI does not test pm_yum_remove_docker."
test_pm_yum_install_docker() {
# run_script 'pm_yum_install_docker'
warn "CI does not test pm_yum_install_docker."
}
23 changes: 23 additions & 0 deletions .scripts/require_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'

require_docker() {
local MINIMUM_DOCKER="20.10.0"
# Find minimum compatible version at https://docs.docker.com/engine/release-notes/
# Note compatibility from https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0
local INSTALLED_DOCKER
if [[ ${FORCE:-} == true ]] && [[ -n ${INSTALL:-} ]]; then
INSTALLED_DOCKER="0"
else
INSTALLED_DOCKER=$( (docker --version 2> /dev/null || echo "0") | sed -E 's/(\S+ )(version )?([0-9][a-zA-Z0-9_.-]*)(, build .*)?/\3/')
fi
if vergt "${MINIMUM_DOCKER}" "${INSTALLED_DOCKER}"; then
run_script 'package_manager_run' install_docker
fi
}

test_require_docker() {
run_script 'require_docker'
docker --version || fatal "Failed to determine docker version.\nFailing command: ${F[C]}docker --version"
}
2 changes: 1 addition & 1 deletion .scripts/run_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ IFS=$'\n\t'

run_install() {
run_script 'update_system'
run_script 'install_docker'
run_script 'require_docker'
run_script 'setup_docker_group'
run_script 'enable_docker_systemd'
run_script 'request_reboot'
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,18 @@ You may choose to rely on DockSTARTer for various changes to your Docker system
sudo reboot
```

- YUM Systems ([CentOS](https://docs.docker.com/install/linux/docker-ce/centos/#os-requirements))
- Pacman Systems (Arch, Manjaro, EndeavourOS, etc.)

```bash
sudo yum install curl git
sudo pacman -Sy curl docker git
bash -c "$(curl -fsSL https://get.dockstarter.com)"
sudo reboot
```

- Pacman Systems (Arch, Manjaro, EndeavourOS, etc.)

> Note that systems with the `pacman` package manager will not install `docker` via the [https://get.docker.com](https://get.docker.com) script that is used for other distros. The instructions below provide information on installing all the required packages manually before installing DockSTARTer.
- YUM Systems ([CentOS](https://docs.docker.com/install/linux/docker-ce/centos/#os-requirements))

```bash
sudo pacman -Sy curl docker git
sudo yum install curl git
bash -c "$(curl -fsSL https://get.dockstarter.com)"
sudo reboot
```
Expand All @@ -86,8 +84,8 @@ The standard install above downloads the initial script using a method with some
## NOTE: Run the appropriate command for your distro
sudo apt-get install curl git
sudo dnf install curl git
sudo pacman -Sy curl git
sudo yum install curl git
sudo pacman -Sy curl docker git
```

Then
Expand Down