#!/bin/sh

# if command -v yay &> /dev/null; then
#     echo "yay is already installed."
#     exit 0;
# fi

echo "This script is going to install yay and it's dependencies. As such it will ask for root privilages."

read -r -p "Are You Sure? [y/N] " input

case $input in
[yY][eE][sS] | [yY])
    echo "The program will continue..."
    ;;
[nN][oO] | [nN])
    exit 0
    ;;
*)
    echo "Invalid input..."
    exit 1
    ;;
esac

if ! command -v git &> /dev/null; then
    sudo pacman -Sy --noconfirm git
fi

if ! command -v fakeroot &> /dev/null; then
    sudo pacman -Sy --noconfirm base-devel
fi

cd /opt
sudo git clone https://aur.archlinux.org/yay.git
sudo chown -R $USER:users ./yay
cd yay
makepkg -si