Splitted update in functions
This commit is contained in:
parent
bd0fc8d864
commit
8e0cf30955
|
@ -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"
|
||||
}
|
||||
|
||||
update-rust() {
|
||||
|
||||
# Update rust if installed
|
||||
command -v rustup > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
start_rust_update=`date +%s`
|
||||
if [ $? -eq 0 ]; then
|
||||
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"
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue