#!/bin/bash

echo
echo "Copying /etc/pacman.d/gnupg/gpg.conf"
echo

file_boolean=0
file="/usr/local/share/snigdhaos/gpg.conf"

# Function to check if the specified file exists
check_file() {
    if [[ -f "$file" ]]; then
        echo "$file exists"
        file_boolean=1
    else
        echo "$file doesn't exist"
        file_boolean=0
    fi
}

# Run the file existence check
check_file

# If the file exists, copy it to the appropriate location
if [ "$file_boolean" -eq 1 ]; then
    echo -e "\nCopying $file to /etc/pacman.d/gnupg/gpg.conf"
    if sudo cp "$file" /etc/pacman.d/gnupg/gpg.conf; then
        echo "/etc/pacman.d/gnupg/gpg.conf copied from local system successfully."
    else
        echo "Error: Failed to copy $file to /etc/pacman.d/gnupg/gpg.conf"
        exit 1
    fi
fi

echo
echo "Task Completed!"
echo
