mirror of
https://github.com/edu4rdshl/archlinux-pkgrecover.git
synced 2026-07-17 23:24:46 +00:00
Fix issues involving sudo and root. (#1)
* 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. * Update pkgrecover.sh Will now check to make sure the important directories are mounted. * Update pkgrecover.sh Will now stop people from trying to install packages without root privileges. * Update pkgrecover.sh --------- Co-authored-by: Eduard Tolosa <tolosaeduard@gmail.com>
This commit is contained in:
parent
07defa580c
commit
0eec8cceb0
1 changed files with 27 additions and 4 deletions
|
|
@ -2,7 +2,26 @@
|
|||
|
||||
VERSION="1.0.0"
|
||||
USE_PACMAN_STATIC=${USE_PACMAN_STATIC:-"false"}
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[1;33m'
|
||||
|
||||
directory_check() {
|
||||
#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."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d /sys]]; then
|
||||
echo -e "${RED} ERROR: /sys is not mounted. upgrading without /sys mounted can cause damage."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d /boot]]; then
|
||||
echo -e "${RED} ERROR: /boot is not mounted. upgrading without /boot mounted can cause damage."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
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 +106,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 +148,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 +172,12 @@ fi
|
|||
|
||||
# Check that we are running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as 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. Proceeding because it's a dry-run operation."
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue