mirror of
https://github.com/Snigdha-OS/snigdhaos-system-config.git
synced 2025-09-21 20:14:58 +02:00
⚡️ perf(improve): better error handling and more robust functionality, while also providing clearer output for the user
This commit is contained in:
@@ -5,23 +5,31 @@ echo "Copying /etc/pacman.d/gnupg/gpg.conf"
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
file_boolean=0
|
file_boolean=0
|
||||||
function check_file() {
|
file="/usr/local/share/snigdhaos/gpg.conf"
|
||||||
|
|
||||||
file="/usr/local/share/snigdhaos/gpg.conf"
|
# Function to check if the specified file exists
|
||||||
if [[ -f $file ]];then
|
check_file() {
|
||||||
echo $file " exists"
|
if [[ -f "$file" ]]; then
|
||||||
file_boolean=1
|
echo "$file exists"
|
||||||
else
|
file_boolean=1
|
||||||
echo $file " doesn't exist"
|
else
|
||||||
file_boolean=0
|
echo "$file doesn't exist"
|
||||||
fi
|
file_boolean=0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run the file existence check
|
||||||
check_file
|
check_file
|
||||||
|
|
||||||
if [ $file_boolean -eq 1 ] ; then
|
# If the file exists, copy it to the appropriate location
|
||||||
sudo cp /usr/local/share/snigdhaos/gpg.conf /etc/pacman.d/gnupg/gpg.conf
|
if [ "$file_boolean" -eq 1 ]; then
|
||||||
echo "/etc/pacman.d/gnupg/gpg.conf copied from local system"
|
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
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
Reference in New Issue
Block a user