pull-dotfiles() { current_dir=$PWD echo "\033[32;1m=== Updating oh-my-zsh ===\033[0m" cd ~/.config/oh-my-zsh && git pull echo "\033[32;1m=== Updating dotfiles ===\033[0m" cd ~/.config/dotfiles && git pull if [ -d ~/.config/awesome/.git ]; then echo "\033[32;1m=== Updating awesome config ===\033[0m" cd ~/.config/awesome/ && git pull fi cd $current_dir } 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=== Updating system ===\033[0m" start_system_update=`date +%s` # Debian based systems command -v apt > /dev/null 2>&1 if [ $? -eq 0 ]; then sudo apt update -y if [ $? -eq 0 ]; then sudo apt upgrade -y if [ $? -eq 0 ]; then sudo apt autoremove -y fi fi fi # Archlinux based systems command -v yaourt > /dev/null 2>&1 if [ $? -eq 0 ]; then yaourt -Syu else command -v pacman > /dev/null 2>&1 if [ $? -eq 0 ]; then sudo pacman -Syu fi fi # Fedora based systems command -v dnf > /dev/null 2>&1 if [ $? -eq 0 ]; then sudo dnf upgrade fi # Update rust if installed command -v rustup > /dev/null 2>&1 seconds=$((`date +%s` - $start_system_update )) formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` echo "\033[32;1m=== System updated in $formatted ===\033[0m" start_rust_update=`date +%s` if [ $? -eq 0 ]; then echo "\033[32;1m=== Updating rustup ===\033[0m" rustup self update echo "\033[32;1m=== Updating rust ===\033[0m" rustup update cargo install-update --help > /dev/null 2>&1 if [ $? -ne 0 ]; then pkg-config --libs --cflags openssl > /dev/null 2>&1 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 # For fedora command -v dnf > /dev/null 2>&1 if [ $? -eq 0 ]; then sudo dnf install openssl-devel fi fi echo "\033[32;1m=== Installing rust packages updater ===\033[0m" cargo install cargo-update fi echo "\033[32;1m=== Updating rust packages ===\033[0m" cargo install-update -ag fi seconds=$((`date +%s` - $start_rust_update )) formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` echo "\033[32;1m=== Rust updated in $formatted ===\033[0m" # Update the dotfiles start_dotfiles_update=`date +%s` pull-dotfiles seconds=$((`date +%s` - $start_dotfiles_update )) formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` echo "\033[32;1m=== Dotfiles updated in $formatted ===\033[0m" seconds=$((`date +%s` - $start_system_update )) formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` echo "\033[32;1m=== Update finished in $formatted ===\033[0m" }