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