From 47a69730a6e7a09d8a71a161683b57d158e306b1 Mon Sep 17 00:00:00 2001 From: mrhoomanwastaken <113311405+mrhoomanwastaken@users.noreply.github.com> Date: Sun, 22 Sep 2024 19:13:24 -0600 Subject: [PATCH] Update pkgrecover.sh Will now stop people from trying to install packages without root privileges. --- pkgrecover.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgrecover.sh b/pkgrecover.sh index e63e4b3..b4b0047 100644 --- a/pkgrecover.sh +++ b/pkgrecover.sh @@ -2,9 +2,10 @@ VERSION="1.0.0" USE_PACMAN_STATIC=${USE_PACMAN_STATIC:-"false"} +RED='\033[0;31m' +YELLOW='\033[1;33m' directory_check() { - RED='\033[0;31m' #checks to make sure that all the important directories are mounted properly if [[ ! -d /proc]]; then echo -e "${RED} ERROR: /proc is not mounted. upgrading without /proc mounted can cause damage." @@ -171,7 +172,12 @@ fi # Check that we are running as root if [[ $EUID -ne 0 ]]; then - echo "WARNING: This script must be run as root in order to install pacman packages. You can still use dryrun without root." + if [[ $3 == "--dry-run" ]] || [[ $2 == "--dry-run" ]]; then + echo -e "${YELLOW}WARNING: This script must be run as root in order to install pacman packages. You can still use dryrun without root." + else + echo -e "${RED}ERROR: This script must be run as root in order to install pacman packages." + exit 1 + fi fi # Parse the command line arguments