From 5be02a47473ddc88b10155398800723b4b169dfa Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Oct 2023 20:36:44 -0500 Subject: [PATCH] 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' }