install.sh: curl bei Bedarf automatisch installieren

Neue Helfer ensure_curl + pkg_install (apt/dnf/yum/apk/pacman/zypper) mit
sudo-Erkennung; wird vor der Docker-Installation aufgerufen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-07-22 09:28:22 +02:00
parent ea67e6c1b0
commit 575dd1a354

View File

@@ -20,6 +20,49 @@ error() { printf '\033[0;31m[x]\033[0m %s\n' "$*" >&2; }
rand() { LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c "${1:-32}"; }
# root/sudo bestimmen
if [[ "$(id -u)" -eq 0 ]]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO=""
fi
# --- Paketinstallation (paketmanager-unabhängig) ------------------------------
pkg_install() {
local pkg="$1"
if command -v apt-get >/dev/null 2>&1; then
$SUDO apt-get update -y && $SUDO apt-get install -y "$pkg"
elif command -v dnf >/dev/null 2>&1; then
$SUDO dnf install -y "$pkg"
elif command -v yum >/dev/null 2>&1; then
$SUDO yum install -y "$pkg"
elif command -v apk >/dev/null 2>&1; then
$SUDO apk add --no-cache "$pkg"
elif command -v pacman >/dev/null 2>&1; then
$SUDO pacman -Sy --noconfirm "$pkg"
elif command -v zypper >/dev/null 2>&1; then
$SUDO zypper install -y "$pkg"
else
return 1
fi
}
# --- curl sicherstellen (wird für die Docker-Installation gebraucht) ----------
ensure_curl() {
if command -v curl >/dev/null 2>&1; then
return 0
fi
warn "curl ist nicht installiert wird jetzt automatisch installiert …"
if ! pkg_install curl; then
error "curl konnte nicht installiert werden (kein bekannter Paketmanager gefunden). Bitte curl manuell installieren und erneut ausführen."
exit 1
fi
command -v curl >/dev/null 2>&1 || { error "curl-Installation fehlgeschlagen."; exit 1; }
info "curl installiert."
}
# --- Docker prüfen / installieren ---------------------------------------------
ensure_docker() {
if command -v docker >/dev/null 2>&1; then
@@ -34,6 +77,7 @@ ensure_docker() {
fi
case "$reply" in
[JjYy]*)
ensure_curl
info "Installiere Docker über get.docker.com …"
curl -fsSL https://get.docker.com | sh
;;