Cleaner sudo
This commit is contained in:
parent
f8352b9f02
commit
43f32ee7ff
48
bin/update
48
bin/update
|
@ -164,11 +164,11 @@ update-system() {
|
||||||
|
|
||||||
if [ -z "$password" ]; then
|
if [ -z "$password" ]; then
|
||||||
echo -e "\033[32;1m=== Starting system update, please enter your password ===\033[0m"
|
echo -e "\033[32;1m=== Starting system update, please enter your password ===\033[0m"
|
||||||
sudo true
|
read -s password
|
||||||
else
|
|
||||||
echo $password | sudo -S true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo $password | sudo -Sp "" true
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Could not get sudo..."
|
echo "Could not get sudo..."
|
||||||
return 1
|
return 1
|
||||||
|
@ -180,29 +180,11 @@ 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
|
||||||
|
echo $password | sudo -Sp "" 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
|
||||||
|
echo $password | sudo -Sp "" apt upgrade -y
|
||||||
if [ -z "$password" ]; then
|
|
||||||
sudo apt upgrade -y
|
|
||||||
else
|
|
||||||
echo $password | sudo -S apt upgrade -y
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
echo $password sudo -Sp "" 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
|
||||||
|
@ -211,24 +193,14 @@ 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
|
||||||
if [ -z "$password" ]; then
|
echo $password | sudo -Sp "" pacman -Syu --noconfirm
|
||||||
sudo pacman -Syu --noconfirm
|
|
||||||
else
|
|
||||||
echo $password | sudo -S pacman -Syu --noconfirm
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -236,11 +208,7 @@ update-system() {
|
||||||
# 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
|
||||||
if [ -z "$password" ]; then
|
echo $password | sudo -Sp "" dnf upgrade
|
||||||
sudo dnf upgrade
|
|
||||||
else
|
|
||||||
echo $password | sudo -S dnf upgrade
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local seconds=$((`date +%s` - $start))
|
local seconds=$((`date +%s` - $start))
|
||||||
|
|
Loading…
Reference in New Issue