From 0551a7484b76de4bd2f6ed95962a628dec98bc56 Mon Sep 17 00:00:00 2001 From: Daniel Nashed Date: Sun, 22 Sep 2024 01:21:07 +0000 Subject: [PATCH] Support for Alpine Linux --- domdownload.sh | 19 ++++++++++++------- install_container_env.sh | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/domdownload.sh b/domdownload.sh index cada69c..9686c07 100755 --- a/domdownload.sh +++ b/domdownload.sh @@ -2,7 +2,7 @@ ########################################################################### # Domino Software Download Script # -# Version 1.0.3 21.07.2024 # +# Version 1.0.5 22.09.2024 # # Copyright Nash!Com, Daniel Nashed # # # # Licensed under the Apache License, Version 2.0 (the "License"); # @@ -46,11 +46,12 @@ # 1.0.2 Add redirect support for custom download option # 1.0.3 Add support for direct download specifying -filename & -fileid and -hash # 1.0.4 Add error checks for fileURL results specially for license accept returned errors +# 1.0.5 Support for Alpine Linux SCRIPT_NAME=$0 SCRIPT_DIR=$(dirname $SCRIPT_NAME) -DOMDOWNLOAD_SCRIPT_VERSION=1.0.4 +DOMDOWNLOAD_SCRIPT_VERSION=1.0.5 # Just print version and exit case "$1" in @@ -300,8 +301,8 @@ install_package() $SUDO /usr/bin/apt-get install -y "$@" - elif [ -x /sbin/apk]; then - $SUDO /sbin/apk add "$@" + elif [ -x /sbin/apk ]; then + $SUDO /sbin/apk add "$@" else @@ -471,13 +472,17 @@ CheckEnvironment() else - CHECKSUM_VERSION=$(sha256sum --version 2>/dev/null | head -1) - CHECKSUM_CMD="sha256sum" + if [ -x /usr/bin/sha256sum ]; then + CHECKSUM_CMD="/usr/bin/sha256sum" + elif [ -x /usr/local/bin/sha256sum ]; then + CHECKSUM_CMD="/usr/local/bin/sha256sum" + fi - if [ -z "$CHECKSUM_VERSION" ]; then + if [ -z "$CHECKSUM_CMD" ]; then LogError "No sha256sum found" exit 1 fi + fi if [ -e /usr/bin/curl ]; then diff --git a/install_container_env.sh b/install_container_env.sh index c6c12f7..ce48f76 100755 --- a/install_container_env.sh +++ b/install_container_env.sh @@ -1,11 +1,11 @@ -#!/bin/bash +#!/bin/sh ############################################################################ # Copyright Nash!Com, Daniel Nashed 2022-2024 - APACHE 2.0 see LICENSE ############################################################################ # Container environment installation script -# Version 1.0.2 24.08.2024 +# Version 1.0.3 22.09.2024 # - Installs required software # - Adds notes:notes user and group @@ -180,6 +180,10 @@ linux_update() apt-get upgrade -y + elif [ -x /sbin/apk ]; then + header "Updating Linux via apk" + apk update + fi } @@ -341,6 +345,9 @@ install_software() # Ubuntu needs different packages and doesn't provide some others install_package bind9-utils + elif [ -x /sbin/apk ]; then + install_packages bash outils-sha256 curl gettext gawk openssl shadow + else # RHEL/CentOS/Fedora @@ -471,6 +478,24 @@ install_container_env() # install_packages docker.io docker-buildx docker-compose-v2 + elif [ -x /sbin/apk ]; then + + # Alpine Linux Docker install + install_package docker + + header "Enabling and starting Docker" + + if [ -x /sbin/openrc ]; then + header "Enabling and starting Docker" + openrc default + rc-service docker start + + rc-update add docker default + openrc default + fi + + return 0 + else # Assume Redhat/CentOS compatible environments @@ -512,6 +537,10 @@ must_be_root() return 0 fi + if [ "$(id -u)" = "0" ]; then + return 0 + fi + log_error "Installation requires root permissions. Switch to root or try 'sudo'" exit 1 }