Better kill even though still not perfect

This commit is contained in:
Thomas Forgione 2019-06-03 17:10:42 +02:00
parent 865fa1c537
commit 08c918b3c0
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 24 additions and 0 deletions

View File

@ -1,5 +1,18 @@
#!/usr/bin/env bash
running=0
_check_running() {
if [ $running -ne 0 ]; then
_unlock
exit $running
fi
}
_onkill() {
running=1
}
_lock() {
if [ -f ~/.config/dotfiles/.data/update_lock ]; then
return 1
@ -356,28 +369,37 @@ main() {
echo -e "\033[32;1m=== Starting full update ===\033[0m"
# Update the system
_check_running
update-system
# Update rust and rust packages
_check_running
update-rust
# Update npm and npm packages
_check_running
update-npm
# Update the dotfiles
_check_running
update-dotfiles
# Update the neovim packages
_check_running
update-neovim
_check_running
update-postpone
_check_running
seconds=$((`date +%s` - $start ))
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
echo -e "\033[32;1m=== Update finished in $formatted ===\033[0m"
_check_running
_check_date_if_format force
_check_running
_unlock
else
@ -402,6 +424,7 @@ main() {
fi
for part in $@; do
_check_running
partial-update $part
done
@ -411,5 +434,6 @@ main() {
fi
}
trap _onkill 2 3
main $@