From 84981d727120903867d4346eab1633e986c22e94 Mon Sep 17 00:00:00 2001 From: humocs-man <251756307+humocs-man@users.noreply.github.com> Date: Sat, 14 Mar 2026 15:16:26 +0100 Subject: [PATCH] Enhance install-homebrew.sh with user validation Added error handling and user check for Homebrew installation. --- files/usr/local/bin/install-homebrew.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/files/usr/local/bin/install-homebrew.sh b/files/usr/local/bin/install-homebrew.sh index 28a50ba..c722012 100644 --- a/files/usr/local/bin/install-homebrew.sh +++ b/files/usr/local/bin/install-homebrew.sh @@ -1,7 +1,20 @@ #!/usr/bin/env bash -set -e +set -euo pipefail + +if [[ -z "${1:-}" ]]; then + echo "Kein Benutzer angegeben – breche ab." >&2 + exit 1 +fi USER="$1" +# Brew bereits vorhanden? +if sudo -u "$USER" command -v brew >/dev/null 2>&1; then + echo "Homebrew ist bereits installiert – überspringe." + exit 0 +fi + +echo "Installiere Homebrew für Benutzer: $USER" + sudo -u "$USER" NONINTERACTIVE=1 \ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"