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() { 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" echo "\033[32;1m=== Updating system ===\033[0m"
start_system_update=`date +%s` start_system_update=`date +%s`
@ -55,9 +73,14 @@ update-rust() {
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
pkg-config --libs --cflags openssl > /dev/null 2>&1 pkg-config --libs --cflags openssl > /dev/null 2>&1
if [ $? -ne 0 ]; then
# We need to install openssl # We need to install openssl
if [ $? -ne 0 ]; then
# Ask for sudo right now
sudoresult=$(sudo -nv 2>&1)
if [ $? -eq 0 ]; then
command -v apt > /dev/null 2>&1 command -v apt > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo apt install -y libssl-dev sudo apt install -y libssl-dev
@ -68,6 +91,17 @@ update-rust() {
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo dnf install openssl-devel sudo dnf install openssl-devel
fi 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 fi
@ -111,15 +145,7 @@ update-dotfiles() {
update() { update() {
start=`date +%s` start=`date +%s`
echo "\033[32;1m=== Starting the update, please enter your password ===\033[0m" echo "\033[32;1m=== Starting update ===\033[0m"
# Ask for sudo right now
sudo true
if [ $? -ne 0 ]; then
echo "Could not get sudo..."
return 1
fi
# Update the system # Update the system
update-system update-system