Compare commits

..

6 Commits

Author SHA1 Message Date
Thomas Forgione fe5ad9f4af Better output 2023-02-24 11:29:17 +01:00
Thomas Forgione f2c4618f5b Missing pipe 2023-02-24 11:27:13 +01:00
Thomas Forgione b74fdc59fd Prompt for password 2023-02-24 11:23:32 +01:00
Thomas Forgione 43f32ee7ff Cleaner sudo 2023-02-24 11:20:40 +01:00
Thomas Forgione f8352b9f02 Fix bug 2023-02-24 11:00:48 +01:00
Thomas Forgione 75bd35b942 Update sudo 2023-02-24 11:00:06 +01:00
1 changed files with 20 additions and 7 deletions

View File

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