#!/bin/bash # Color definitions for output Green='\033[0;32m' NC='\033[0m' # No Color # Function to check if a command exists command_exists() { command -v "$1" >/dev/null 2>&1 } # Function to check if Chaotic-AUR is already enabled in pacman.conf check_chaotic_aur_enabled() { if grep -q '^\[chaotic-aur\]' /etc/pacman.conf && grep -q 'Include = /etc/pacman.d/chaotic-mirrorlist' /etc/pacman.conf; then return 0 else return 1 fi } # Function to check if mirrorlist exists check_mirror_exists() { if test -f "/etc/pacman.d/chaotic-mirrorlist"; then return 0 else return 1 fi } # Function to setup mirrorlist setup_mirrorlist() { echo -e "${Green}Downloading Chaotic-AUR mirrorlist...${NC}" wget -q -O chaotic-mirrorlist "https://raw.githubusercontent.com/chaotic-aur/pkgbuild-chaotic-mirrorlist/main/mirrorlist" sudo mv chaotic-mirrorlist /etc/pacman.d/chaotic-mirrorlist echo -e "${Green}Mirrorlist installed successfully.${NC}" } # Function to append Chaotic-AUR to pacman.conf append_pacman_conf() { echo -e "${Green}Adding Chaotic-AUR to pacman.conf...${NC}" echo "" | sudo tee -a /etc/pacman.conf > /dev/null echo "#Chaotic-AUR" | sudo tee -a /etc/pacman.conf > /dev/null echo "[chaotic-aur]" | sudo tee -a /etc/pacman.conf > /dev/null echo "Include = /etc/pacman.d/chaotic-mirrorlist" | sudo tee -a /etc/pacman.conf > /dev/null echo -e "${Green}Configuration added to pacman.conf.${NC}" } # Function to initialize and sign keys setup_keys() { echo -e "${Green}Initializing and signing Chaotic-AUR keys...${NC}" sudo pacman-key --recv-key 3056513887B78AEB --keyserver hkp://keyserver.ubuntu.com:80 sudo pacman-key --lsign-key 3056513887B78AEB echo -e "${Green}Keys signed successfully.${NC}" } # Function to install keyring packages install_keyring() { echo -e "${Green}Installing Chaotic-AUR keyring and mirrorlist packages...${NC}" sudo pacman -U --noconfirm \ 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' \ 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' echo -e "${Green}Keyring packages installed.${NC}" } # Main Execution echo "Starting Chaotic-AUR Installation/Configuration..." # 1. Check if already installed and enabled if check_chaotic_aur_enabled; then echo -e "${Green}Chaotic-AUR is already installed and enabled in pacman.conf.${NC}" echo "Checking for updates..." sudo pacman -Syu chaotic-keyring exit 0 fi # 2. Check if mirrorlist exists, if not, download it if ! check_mirror_exists; then setup_mirrorlist else echo -e "${Green}Mirrorlist already exists.${NC}" fi # 3. Ensure system is up-to-date before adding new repo echo -e "${Green}Updating system packages...${NC}" sudo pacman -Syu --noconfirm # 4. Setup Keys setup_keys # 5. Install Keyring install_keyring # 6. Append to pacman.conf append_pacman_conf # 7. Refresh database echo -e "${Green}Refreshing pacman database...${NC}" sudo pacman -Sy echo -e "${Green}Chaotic-AUR installation and configuration complete.${NC}" echo "You can now install packages from Chaotic-AUR using 'pacman -S ' or 'paru -S '." #!/bin/env bash