Updated update script

This commit is contained in:
Thomas Forgione 2019-01-08 11:16:43 +01:00
parent 8e0cf30955
commit b775cde688
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 43 additions and 17 deletions

View File

@ -1,4 +1,22 @@
update-system() {
# Ask for sudo right now
sudoresult=$(sudo -nv 2>&1)
if [ $? -eq 0 ]; then
# Nothing to do
elif echo $sudoresult | grep -q '^sudo:'; then
echo "\033[32;1m=== Starting system update, please enter your password ===\033[0m"
sudo true
if [ $? -ne 0 ]; then
echo "Could not get sudo..."
return 1
fi
else
echo "\033[33;1m=== You are not a sudoer, skipping system update... ===\033[0m"
return 1
fi
echo "\033[32;1m=== Updating system ===\033[0m"
start_system_update=`date +%s`
@ -55,18 +73,34 @@ update-rust() {
if [ $? -ne 0 ]; then
pkg-config --libs --cflags openssl > /dev/null 2>&1
# We need to install openssl
if [ $? -ne 0 ]; then
# We need to install openssl
command -v apt > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo apt install -y libssl-dev
fi
# Ask for sudo right now
sudoresult=$(sudo -nv 2>&1)
# For fedora
command -v dnf > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo dnf install openssl-devel
command -v apt > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo apt install -y libssl-dev
fi
# For fedora
command -v dnf > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo dnf install openssl-devel
fi
elif echo $sudoresult | grep -q '^sudo:'; then
echo "\033[32;1m=== libssl-dev is needed to update rust packages, please enter your password ===\033[0m"
sudo true
if [ $? -ne 0 ]; then
echo "Could not get sudo..."
return 1
fi
else
echo "\033[33;1m=== You are not a sudoer, cannot install cargo-update... ===\033[0m"
return 1
fi
fi
@ -111,15 +145,7 @@ update-dotfiles() {
update() {
start=`date +%s`
echo "\033[32;1m=== Starting the update, please enter your password ===\033[0m"
# Ask for sudo right now
sudo true
if [ $? -ne 0 ]; then
echo "Could not get sudo..."
return 1
fi
echo "\033[32;1m=== Starting update ===\033[0m"
# Update the system
update-system