Skip to content

Instantly share code, notes, and snippets.

@felipealfonsog
Last active March 18, 2024 15:32
Show Gist options
  • Save felipealfonsog/6e958ac8268fd31c76bfdf9c91d9aa9d to your computer and use it in GitHub Desktop.
Save felipealfonsog/6e958ac8268fd31c76bfdf9c91d9aa9d to your computer and use it in GitHub Desktop.
This bash script installs Yay, a package manager for Arch Linux, from its source on the Arch User Repository (AUR). It checks if the user is in their home directory and prompts for confirmation before proceeding. The script then removes any existing Yay installation, clones the Yay repository, builds and installs it, and cleans up temporary file…
#!/bin/bash
#------------------------
# By Felipe Alfonso González
# Computer Science Engineer
# github.com/felipealfonsog
# f.alfonso.go@res-ear.ch
#------------------------
# Follow this commands before executing:
# chmod +x install_yay.sh
# ./install_yay.sh
#------------------------
# Check if user is in home directory
if [[ "$PWD" != "$HOME" ]]; then
echo "Please run this script from your home directory."
exit 1
fi
# Prompt user for confirmation
read -rp "Are you sure you want to install Yay? (Y/n): " answer
if [[ -z "$answer" || "$answer" =~ ^[Yy]$ ]]; then
# Fetch SSL certificates if missing
if [ ! -f "/etc/ssl/certs/ca-certificates.crt" ]; then
echo "Fetching SSL certificates..."
sudo pacman -Sy ca-certificates --noconfirm
fi
echo "Installing Yay from git..."
git clone https://aur.archlinux.org/yay.git yay-install
cd yay-install || exit
makepkg -si
cd ..
rm -rf yay-install
echo "Yay installed successfully."
else
echo "Installation aborted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment