fix: ensure Homebrew installation runs as non-root user with proper permissions
This commit is contained in:
parent
ac31a224a2
commit
101c1cda1c
1 changed files with 9 additions and 2 deletions
|
@ -67,8 +67,15 @@ sudo apt install linux-xanmod-x64v3 -y
|
||||||
|
|
||||||
# Homebrew
|
# Homebrew
|
||||||
echo "Installing Homebrew..."
|
echo "Installing Homebrew..."
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) --prefix=/opt/homebrew"
|
if [[ -z "$SUDO_USER" ]]; then
|
||||||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bashrc
|
echo "Error: Script must be run with sudo by a non-root user (SUDO_USER not set)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Run Homebrew installer as the original user
|
||||||
|
sudo -u "$SUDO_USER" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) --prefix=/opt/homebrew"
|
||||||
|
# Add Homebrew to the user's .bashrc
|
||||||
|
echo "eval \"\$(/opt/homebrew/bin/brew shellenv)\"" | sudo -u "$SUDO_USER" tee -a "/home/$SUDO_USER/.bashrc" > /dev/null
|
||||||
|
# Ensure Homebrew is available in the current session
|
||||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||||
|
|
||||||
# Pacstall
|
# Pacstall
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue