From 339b011db8206869b726cea7a3ccbea65c519d99 Mon Sep 17 00:00:00 2001 From: humocs-man <251756307+humocs-man@users.noreply.github.com> Date: Sun, 15 Mar 2026 17:59:18 +0100 Subject: [PATCH] Refactor Homebrew installation script Removed user check and installation confirmation for Homebrew. Added export of HOME and updated installation command. --- files/usr/local/bin/install-homebrew.sh | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/files/usr/local/bin/install-homebrew.sh b/files/usr/local/bin/install-homebrew.sh index c722012..60e5118 100644 --- a/files/usr/local/bin/install-homebrew.sh +++ b/files/usr/local/bin/install-homebrew.sh @@ -1,20 +1,17 @@ #!/usr/bin/env bash set -euo pipefail -if [[ -z "${1:-}" ]]; then - echo "Kein Benutzer angegeben – breche ab." >&2 - exit 1 -fi - USER="$1" +HOME="/var/home/$USER" +export HOME +export NONINTERACTIVE=1 -# Brew bereits vorhanden? -if sudo -u "$USER" command -v brew >/dev/null 2>&1; then - echo "Homebrew ist bereits installiert – überspringe." - exit 0 + +# Homebrew installieren (als User, aber ohne Interaktion) +sudo -u "$USER" HOME="$HOME" NONINTERACTIVE=1 bash -c \ + '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' + +# Optional: Brew in PATH eintragen +if ! grep -q 'linuxbrew' "$HOME/.bashrc"; then + echo 'eval "$(/var/home/'"$USER"'/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> "$HOME/.bashrc" 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)"