From 64fcac7d85e4a5a8b6ff1cc7ace227d69cb47733 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 2 Jan 2024 11:08:57 -0800 Subject: [PATCH] Add scripts to enable multilib and install yay This commit adds two new scripts: `enable-multilib.sh` and `install-yay-arch.sh`. The `enable-multilib.sh` script enables multilib libraries by uncommenting the [multilib] section in `/etc/pacman.conf` and updating the system. The `install-yay-arch.sh` script installs yay, a package manager for Arch Linux, if it is not already installed. Both scripts include error handling and custom error messages. --- scripts/enable-multilib.sh | 28 ++++++++++++++++++++++++++ scripts/install-yay-arch.sh | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 scripts/enable-multilib.sh create mode 100644 scripts/install-yay-arch.sh diff --git a/scripts/enable-multilib.sh b/scripts/enable-multilib.sh new file mode 100644 index 0000000..e7fc5ba --- /dev/null +++ b/scripts/enable-multilib.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Exit if any command fails and treat unset variables as an error +set -eu + +# Function to execute a command and print a custom error message if it fails +execute() { + echo "$2" + $1 +} + +# Ensure the script is being run with superuser privileges +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +# Function to enable multilib libraries +enable_multilib() { + # Uncomment the [multilib] section in /etc/pacman.conf + execute "sed -i '/\[multilib\]/,/Include/s/^#//g' /etc/pacman.conf" "Enabling multilib libraries..." + + # Update the system + execute "pacman -Sy" "Updating the system..." +} + +# Call the function to enable multilib libraries +enable_multilib \ No newline at end of file diff --git a/scripts/install-yay-arch.sh b/scripts/install-yay-arch.sh new file mode 100644 index 0000000..ed32c79 --- /dev/null +++ b/scripts/install-yay-arch.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Exit if any command fails and treat unset variables as an error +set -eu + +# Function to execute a command and print a custom error message if it fails +execute() { + echo "$2" + $1 +} + +# Ensure the script is being run with superuser privileges +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +# Function to install yay +install_yay() { + # Check if yay is already installed + if ! command -v yay &> /dev/null; then + execute "git clone https://aur.archlinux.org/yay.git" "Cloning yay repository..." + cd yay + execute "makepkg -si --noconfirm" "Building and installing yay..." + cd .. + execute "rm -rf yay" "Cleaning up..." + else + echo "yay is already installed." + fi + + # Validate installation + if command -v yay &> /dev/null; then + echo "yay is installed successfully." + else + echo "Failed to install yay." + fi +} + +# Call the function to install yay +install_yay \ No newline at end of file