Fix issues involving sudo and root.

Removed the usage of sudo in the script because it stops pacman from running.
The script will now warn you if you are not root, but it will not stop the script from running to allow usage of dry-run without root privileges.
This commit is contained in:
mrhoomanwastaken 2024-09-22 15:56:01 -06:00 committed by GitHub
parent 07defa580c
commit 09041a47c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@
VERSION="1.0.0"
USE_PACMAN_STATIC=${USE_PACMAN_STATIC:-"false"}
install_pacman_static() {
if [[ ! -f /tmp/pacman-static.installed ]]; then
echo "Downloading and installing pacman-static. In case that curl fails, you can download the binary from:"
@ -87,7 +88,7 @@ using_pacman_db() {
done
else
echo "Reinstalling the following packages:"
sudo pacman -S "${matching_packages[@]}" --overwrite='*'
pacman -S "${matching_packages[@]}" --overwrite='*'
fi
cleanup
@ -129,7 +130,7 @@ using_paclog() {
done
else
echo "Reinstalling the following packages:"
sudo pacman -S "${matching_packages[@]}" --overwrite='*'
pacman -S "${matching_packages[@]}" --overwrite='*'
fi
cleanup
@ -153,8 +154,7 @@ fi
# Check that we are running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
echo "WARNING: This script must be run as root in order to install pacman packages. You can still use dryrun without root."
fi
# Parse the command line arguments