Splitted update in functions

This commit is contained in:
Thomas Forgione 2019-01-07 14:25:56 +01:00
parent bd0fc8d864
commit 8e0cf30955
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 50 additions and 36 deletions

View File

@ -1,33 +1,4 @@
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
update-system() {
echo "\033[32;1m=== Updating system ===\033[0m"
start_system_update=`date +%s`
@ -61,15 +32,18 @@ update() {
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`
update-rust() {
# Update rust if installed
command -v rustup > /dev/null 2>&1
if [ $? -eq 0 ]; then
start_rust_update=`date +%s`
echo "\033[32;1m=== Updating rustup ===\033[0m"
rustup self update
@ -109,15 +83,55 @@ update() {
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
echo "\033[32;1m=== Rust updated in $formatted ===\033[0m"
# Update the dotfiles
}
update-dotfiles() {
start_dotfiles_update=`date +%s`
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
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"
}
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
# Update the system
update-system
# Update rust and rust packages
update-rust
# Update the dotfiles
update-dotfiles
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"
}