Update sudo

This commit is contained in:
Thomas Forgione 2023-02-24 11:00:06 +01:00
parent 61317b5483
commit 75bd35b942
1 changed files with 52 additions and 7 deletions

View File

@ -162,8 +162,13 @@ update-system() {
return return
fi fi
echo -e "\033[32;1m=== Starting system update, please enter your password ===\033[0m" if [ -z "$password" ]; then
sudo true echo -e "\033[32;1m=== Starting system update, please enter your password ===\033[0m"
sudo true
else
echo $password | sudo -S true
fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Could not get sudo..." echo "Could not get sudo..."
return 1 return 1
@ -175,11 +180,29 @@ update-system() {
# Debian based systems # Debian based systems
command -v apt > /dev/null 2>&1 command -v apt > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo apt update -y
if [ -z "$password" ]; then
sudo apt update -y
else
echo $password | sudo -S apt update -y
fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo apt upgrade -y
if [ -z "$password" ]; then
sudo apt upgrade -y
else
echo $password | sudo -S apt uprgade -y
fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo apt autoremove -y
if [ -z "$password" ]; then
sudo apt autoremove -y
else
echo $password | sudo -S apt autoremove -y
fi
fi fi
fi fi
fi fi
@ -188,20 +211,36 @@ update-system() {
command -v yay > /dev/null 2>&1 command -v yay > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ ! -z "$password" ]; then
echo $password | sudo -S true
fi
yay -Syu --noconfirm yay -Syu --noconfirm
yay -Syua --noconfirm yay -Syua --noconfirm
else else
command -v pacman > /dev/null 2>&1 command -v pacman > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo pacman -Syu --noconfirm if [ -z "$password" ]; then
sudo pacman -Syu --noconfirm
else
echo $password | sudo -S pacman -Syu --noconfirm
fi
fi fi
fi fi
# Fedora based systems # Fedora based systems
command -v dnf > /dev/null 2>&1 command -v dnf > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo dnf upgrade if [ -z "$password" ]; then
sudo dnf upgrade
else
echo $password | sudo -S dnf upgrade
fi
fi fi
local seconds=$((`date +%s` - $start)) local seconds=$((`date +%s` - $start))
@ -463,6 +502,12 @@ partial-update() {
main() { main() {
if [ "$1" == "--pass" ]; then
shift
password=$1
shift
fi
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
_lock_or_error_message _lock_or_error_message
local error_code=$? local error_code=$?