Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created June 28, 2024 09:15
Show Gist options
  • Save naranyala/ea08a105a3a2dc33b6da7d34cee7e350 to your computer and use it in GitHub Desktop.
Save naranyala/ea08a105a3a2dc33b6da7d34cee7e350 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Function to print a message in a specific format
print_message() {
echo "--------------------------------------------------"
echo "$1"
echo "--------------------------------------------------"
}
# Function to install Homebrew
install_homebrew() {
print_message "Starting Homebrew Installation"
# Check for sudo/root privileges
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run with sudo/root privileges."
exit 1
fi
# Install dependencies
print_message "Installing dependencies"
apt-get update
apt-get install -y build-essential procps curl file git
# Clone the Homebrew repository
print_message "Cloning Homebrew repository"
git clone https://github.com/Homebrew/brew homebrew
# Set up Homebrew environment
print_message "Setting up Homebrew environment"
eval "$(homebrew/bin/brew shellenv)"
# Update Homebrew
print_message "Updating Homebrew"
brew update --force --quiet
# Fix permissions
print_message "Fixing permissions"
chmod -R go-w "$(brew --prefix)/share/zsh"
# Verify the installation
print_message "Verifying Homebrew installation"
if command -v brew &>/dev/null; then
echo "Homebrew was installed successfully."
brew --version
else
echo "There was an issue installing Homebrew."
fi
}
# Start the installation process
install_homebrew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment