From a7ae7d184855fe1b514c28fa64c978fd865bc285 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 20 Sep 2023 18:07:09 -0500 Subject: [PATCH 1/5] feat: :sparkles: add apk for alpine support Signed-off-by: Eric Nemchik --- .scripts/package_manager_run.sh | 4 +++- .scripts/pm_apk_clean.sh | 11 +++++++++++ .scripts/pm_apk_install.sh | 17 +++++++++++++++++ .scripts/pm_apk_install_docker.sh | 18 ++++++++++++++++++ .scripts/pm_apk_repos.sh | 11 +++++++++++ .scripts/pm_apk_upgrade.sh | 18 ++++++++++++++++++ README.md | 8 ++++++++ 7 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .scripts/pm_apk_clean.sh create mode 100644 .scripts/pm_apk_install.sh create mode 100644 .scripts/pm_apk_install_docker.sh create mode 100644 .scripts/pm_apk_repos.sh create mode 100644 .scripts/pm_apk_upgrade.sh diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index 63248e3fb6..fb3bdba010 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -4,7 +4,9 @@ IFS=$'\n\t' package_manager_run() { local ACTION=${1-} - if [[ -n "$(command -v apt-get)" ]]; then + if [[ -n "$(command -v apk)" ]]; then + run_script "pm_apk_${ACTION}" + elif [[ -n "$(command -v apt-get)" ]]; then run_script "pm_apt_${ACTION}" elif [[ -n "$(command -v dnf)" ]]; then run_script "pm_dnf_${ACTION}" diff --git a/.scripts/pm_apk_clean.sh b/.scripts/pm_apk_clean.sh new file mode 100644 index 0000000000..f5e2dd1ec1 --- /dev/null +++ b/.scripts/pm_apk_clean.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +IFS=$'\n\t' + +pm_apk_clean() { + info "apk does not require cleanup." +} + +test_pm_apk_clean() { + run_script 'pm_apk_clean' +} diff --git a/.scripts/pm_apk_install.sh b/.scripts/pm_apk_install.sh new file mode 100644 index 0000000000..e734b3f8b8 --- /dev/null +++ b/.scripts/pm_apk_install.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +IFS=$'\n\t' + +pm_apk_install() { + 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 "sudo apk add coreutils curl git grep newt sed ${REDIRECT}" || fatal "Failed to install dependencies from apk.\nFailing command: ${F[C]}sudo apk add coreutils curl git grep newt sed" +} + +test_pm_apk_install() { + run_script 'pm_apk_repos' + run_script 'pm_apk_install' +} diff --git a/.scripts/pm_apk_install_docker.sh b/.scripts/pm_apk_install_docker.sh new file mode 100644 index 0000000000..7b8671dac2 --- /dev/null +++ b/.scripts/pm_apk_install_docker.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +IFS=$'\n\t' + +pm_apk_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 "sudo apk add docker docker-cli-compose ${REDIRECT}" || fatal "Failed to install docker and docker-compose using pacman.\nFailing command: ${F[C]}sudo apk add docker docker-cli-compose" + +} + +test_pm_apk_install_docker() { + run_script 'pm_apk_repos' + run_script 'pm_apk_install_docker' +} diff --git a/.scripts/pm_apk_repos.sh b/.scripts/pm_apk_repos.sh new file mode 100644 index 0000000000..d40c790b67 --- /dev/null +++ b/.scripts/pm_apk_repos.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +IFS=$'\n\t' + +pm_apk_repos() { + info "apk does not require additional repositories." +} + +test_pm_apk_repos() { + run_script 'pm_apk_repos' +} diff --git a/.scripts/pm_apk_upgrade.sh b/.scripts/pm_apk_upgrade.sh new file mode 100644 index 0000000000..e168901883 --- /dev/null +++ b/.scripts/pm_apk_upgrade.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +IFS=$'\n\t' + +pm_apk_upgrade() { + if [[ ${CI-} != true ]]; then + notice "Upgrading packages. 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 "sudo apk upgrade ${REDIRECT}" || fatal "Failed to upgrade packages from apk.\nFailing command: ${F[C]}sudo apk upgrade" + fi +} + +test_pm_apk_upgrade() { + run_script 'pm_apk_upgrade' +} diff --git a/README.md b/README.md index 560e0b9c9c..6db46a15d2 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,14 @@ You may choose to rely on DockSTARTer for various changes to your Docker system ### One Time Setup (required) +- APK Systems (Alpine) + + ```bash + sudo apk add curl git + bash -c "$(curl -fsSL https://get.dockstarter.com)" + sudo reboot + ``` + - APT Systems ([Debian](https://docs.docker.com/install/linux/docker-ce/debian/#os-requirements), [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/#os-requirements), etc) ```bash From 5be02a47473ddc88b10155398800723b4b169dfa Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Oct 2023 20:36:44 -0500 Subject: [PATCH 2/5] Add support for OpenRC Signed-off-by: Eric Nemchik --- .scripts/enable_docker_service.sh | 28 ++++++++++++++++++++++++++++ .scripts/enable_docker_systemd.sh | 18 ------------------ .scripts/pm_apk_install.sh | 2 +- .scripts/run_install.sh | 2 +- 4 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 .scripts/enable_docker_service.sh delete mode 100644 .scripts/enable_docker_systemd.sh diff --git a/.scripts/enable_docker_service.sh b/.scripts/enable_docker_service.sh new file mode 100644 index 0000000000..6c483ef70f --- /dev/null +++ b/.scripts/enable_docker_service.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +IFS=$'\n\t' + +enable_docker_service() { + DOCKER_SERVICE_ENABLE="" + DOCKER_SERVICE_START="" + if [[ -n "$(command -v systemctl)" ]]; then + info "Systemd detected." + DOCKER_SERVICE_ENABLE="systemctl enable docker" + DOCKER_SERVICE_START="systemctl start docker" + elif [[ -n "$(command -v rc-update)" ]]; then + info "OpenRC detected." + DOCKER_SERVICE_ENABLE="rc-update add docker boot" + DOCKER_SERVICE_START="service docker start" + fi + if [[ -n "${DOCKER_SERVICE_ENABLE}" ]]; then + info "Enabling docker service." + sudo "${DOCKER_SERVICE_ENABLE}" > /dev/null 2>&1 || fatal "Failed to enable docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_ENABLE}" + info "Starting docker service." + sudo "${DOCKER_SERVICE_START}" > /dev/null 2>&1 || fatal "Failed to start docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_START}" + fi +} + +test_enable_docker_service() { + run_script 'require_docker' + run_script 'enable_docker_service' +} diff --git a/.scripts/enable_docker_systemd.sh b/.scripts/enable_docker_systemd.sh deleted file mode 100644 index 7ac516c1ff..0000000000 --- a/.scripts/enable_docker_systemd.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -IFS=$'\n\t' - -enable_docker_systemd() { - # https://docs.docker.com/install/linux/linux-postinstall/ - if [[ -L "/sbin/init" ]]; then - info "Systemd detected. Enabling docker service." - sudo systemctl enable docker > /dev/null 2>&1 || fatal "Failed to enable docker service.\nFailing command: ${F[C]}systemctl enable docker" - info "Starting docker service." - sudo systemctl start docker > /dev/null 2>&1 || fatal "Failed to start docker service.\nFailing command: ${F[C]}systemctl start docker" - fi -} - -test_enable_docker_systemd() { - run_script 'require_docker' - run_script 'enable_docker_systemd' -} diff --git a/.scripts/pm_apk_install.sh b/.scripts/pm_apk_install.sh index e734b3f8b8..9e02a14482 100644 --- a/.scripts/pm_apk_install.sh +++ b/.scripts/pm_apk_install.sh @@ -8,7 +8,7 @@ pm_apk_install() { if [[ -n ${VERBOSE-} ]] || run_script 'question_prompt' "${PROMPT:-CLI}" N "Would you like to display the command output?"; then REDIRECT="" fi - eval "sudo apk add coreutils curl git grep newt sed ${REDIRECT}" || fatal "Failed to install dependencies from apk.\nFailing command: ${F[C]}sudo apk add coreutils curl git grep newt sed" + eval "sudo apk add coreutils curl git grep newt openrc sed ${REDIRECT}" || fatal "Failed to install dependencies from apk.\nFailing command: ${F[C]}sudo apk add coreutils curl git grep newt sed" } test_pm_apk_install() { diff --git a/.scripts/run_install.sh b/.scripts/run_install.sh index fac03fed7c..1425432250 100644 --- a/.scripts/run_install.sh +++ b/.scripts/run_install.sh @@ -6,7 +6,7 @@ run_install() { run_script 'update_system' run_script 'require_docker' run_script 'setup_docker_group' - run_script 'enable_docker_systemd' + run_script 'enable_docker_service' run_script 'request_reboot' } From 1df6f4ae518452eac5e776c4ab1ace6b427565b1 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Oct 2023 20:44:05 -0500 Subject: [PATCH 3/5] fix: :bug: use eval for enable/start Signed-off-by: Eric Nemchik --- .scripts/enable_docker_service.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.scripts/enable_docker_service.sh b/.scripts/enable_docker_service.sh index 6c483ef70f..292aa1b745 100644 --- a/.scripts/enable_docker_service.sh +++ b/.scripts/enable_docker_service.sh @@ -16,9 +16,9 @@ enable_docker_service() { fi if [[ -n "${DOCKER_SERVICE_ENABLE}" ]]; then info "Enabling docker service." - sudo "${DOCKER_SERVICE_ENABLE}" > /dev/null 2>&1 || fatal "Failed to enable docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_ENABLE}" + eval "sudo ${DOCKER_SERVICE_ENABLE}" > /dev/null 2>&1 || fatal "Failed to enable docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_ENABLE}" info "Starting docker service." - sudo "${DOCKER_SERVICE_START}" > /dev/null 2>&1 || fatal "Failed to start docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_START}" + eval "sudo ${DOCKER_SERVICE_START}" > /dev/null 2>&1 || fatal "Failed to start docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_START}" fi } From f0d0c9463e8d8296ddb75d9afb9d1271b29b3299 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Oct 2023 20:57:38 -0500 Subject: [PATCH 4/5] build: :bug: gha does not have apk Signed-off-by: Eric Nemchik --- .scripts/pm_apk_clean.sh | 3 ++- .scripts/pm_apk_install.sh | 5 +++-- .scripts/pm_apk_install_docker.sh | 5 +++-- .scripts/pm_apk_repos.sh | 3 ++- .scripts/pm_apk_upgrade.sh | 3 ++- .scripts/pm_dnf_install.sh | 1 + .scripts/pm_dnf_install_docker.sh | 1 + .scripts/pm_pacman_install.sh | 1 + .scripts/pm_pacman_install_docker.sh | 1 + .scripts/pm_yum_install.sh | 1 + .scripts/pm_yum_install_docker.sh | 1 + 11 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.scripts/pm_apk_clean.sh b/.scripts/pm_apk_clean.sh index f5e2dd1ec1..45bc29e418 100644 --- a/.scripts/pm_apk_clean.sh +++ b/.scripts/pm_apk_clean.sh @@ -7,5 +7,6 @@ pm_apk_clean() { } test_pm_apk_clean() { - run_script 'pm_apk_clean' + # run_script 'pm_apk_clean' + warn "CI does not test pm_apk_clean." } diff --git a/.scripts/pm_apk_install.sh b/.scripts/pm_apk_install.sh index 9e02a14482..396126422e 100644 --- a/.scripts/pm_apk_install.sh +++ b/.scripts/pm_apk_install.sh @@ -12,6 +12,7 @@ pm_apk_install() { } test_pm_apk_install() { - run_script 'pm_apk_repos' - run_script 'pm_apk_install' + # run_script 'pm_apk_repos' + # run_script 'pm_apk_install' + warn "CI does not test pm_apk_install." } diff --git a/.scripts/pm_apk_install_docker.sh b/.scripts/pm_apk_install_docker.sh index 7b8671dac2..0e37644c04 100644 --- a/.scripts/pm_apk_install_docker.sh +++ b/.scripts/pm_apk_install_docker.sh @@ -13,6 +13,7 @@ pm_apk_install_docker() { } test_pm_apk_install_docker() { - run_script 'pm_apk_repos' - run_script 'pm_apk_install_docker' + # run_script 'pm_apk_repos' + # run_script 'pm_apk_install_docker' + warn "CI does not test pm_apk_install_docker." } diff --git a/.scripts/pm_apk_repos.sh b/.scripts/pm_apk_repos.sh index d40c790b67..27369dbf31 100644 --- a/.scripts/pm_apk_repos.sh +++ b/.scripts/pm_apk_repos.sh @@ -7,5 +7,6 @@ pm_apk_repos() { } test_pm_apk_repos() { - run_script 'pm_apk_repos' + # run_script 'pm_apk_repos' + warn "CI does not test pm_apk_repos." } diff --git a/.scripts/pm_apk_upgrade.sh b/.scripts/pm_apk_upgrade.sh index e168901883..c25367f655 100644 --- a/.scripts/pm_apk_upgrade.sh +++ b/.scripts/pm_apk_upgrade.sh @@ -14,5 +14,6 @@ pm_apk_upgrade() { } test_pm_apk_upgrade() { - run_script 'pm_apk_upgrade' + # run_script 'pm_apk_upgrade' + warn "CI does not test pm_apk_upgrade." } diff --git a/.scripts/pm_dnf_install.sh b/.scripts/pm_dnf_install.sh index 890900902b..c3ac7dbf65 100644 --- a/.scripts/pm_dnf_install.sh +++ b/.scripts/pm_dnf_install.sh @@ -12,6 +12,7 @@ pm_dnf_install() { } test_pm_dnf_install() { + # run_script 'pm_dnf_repos' # run_script 'pm_dnf_install' warn "CI does not test pm_dnf_install." } diff --git a/.scripts/pm_dnf_install_docker.sh b/.scripts/pm_dnf_install_docker.sh index d182c0c51c..f97352ad27 100644 --- a/.scripts/pm_dnf_install_docker.sh +++ b/.scripts/pm_dnf_install_docker.sh @@ -21,6 +21,7 @@ pm_dnf_install_docker() { } test_pm_dnf_install_docker() { + # run_script 'pm_dnf_repos' # run_script 'pm_dnf_install_docker' warn "CI does not test pm_dnf_install_docker." } diff --git a/.scripts/pm_pacman_install.sh b/.scripts/pm_pacman_install.sh index 74a17fb745..13637f819c 100644 --- a/.scripts/pm_pacman_install.sh +++ b/.scripts/pm_pacman_install.sh @@ -12,6 +12,7 @@ pm_pacman_install() { } test_pm_pacman_install() { + # run_script 'pm_pacman_repos' # run_script 'pm_pacman_install' warn "CI does not test pm_pacman_install." } diff --git a/.scripts/pm_pacman_install_docker.sh b/.scripts/pm_pacman_install_docker.sh index db2116c3de..336bd6d1b7 100644 --- a/.scripts/pm_pacman_install_docker.sh +++ b/.scripts/pm_pacman_install_docker.sh @@ -12,6 +12,7 @@ pm_pacman_install_docker() { } test_pm_pacman_install_docker() { + # run_script 'pm_pacman_repos' # run_script 'pm_pacman_install_docker' warn "CI does not test pm_pacman_install_docker." } diff --git a/.scripts/pm_yum_install.sh b/.scripts/pm_yum_install.sh index 6d9d18445e..10b4a866cf 100644 --- a/.scripts/pm_yum_install.sh +++ b/.scripts/pm_yum_install.sh @@ -12,6 +12,7 @@ pm_yum_install() { } test_pm_yum_install() { + # run_script 'pm_yum_repos' # run_script 'pm_yum_install' warn "CI does not test pm_yum_install." } diff --git a/.scripts/pm_yum_install_docker.sh b/.scripts/pm_yum_install_docker.sh index eba5800052..2b863382d1 100644 --- a/.scripts/pm_yum_install_docker.sh +++ b/.scripts/pm_yum_install_docker.sh @@ -19,6 +19,7 @@ pm_yum_install_docker() { } test_pm_yum_install_docker() { + # run_script 'pm_yum_repos' # run_script 'pm_yum_install_docker' warn "CI does not test pm_yum_install_docker." } From 74a282052cebc8d320ea0d56975023c48ed420c3 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Oct 2023 21:04:17 -0500 Subject: [PATCH 5/5] style: :lipstick: shfmt fix Signed-off-by: Eric Nemchik --- .scripts/enable_docker_service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/enable_docker_service.sh b/.scripts/enable_docker_service.sh index 292aa1b745..3e08f891b1 100644 --- a/.scripts/enable_docker_service.sh +++ b/.scripts/enable_docker_service.sh @@ -14,7 +14,7 @@ enable_docker_service() { DOCKER_SERVICE_ENABLE="rc-update add docker boot" DOCKER_SERVICE_START="service docker start" fi - if [[ -n "${DOCKER_SERVICE_ENABLE}" ]]; then + if [[ -n ${DOCKER_SERVICE_ENABLE} ]]; then info "Enabling docker service." eval "sudo ${DOCKER_SERVICE_ENABLE}" > /dev/null 2>&1 || fatal "Failed to enable docker service.\nFailing command: ${F[C]}${DOCKER_SERVICE_ENABLE}" info "Starting docker service."