From fff413e04e42ddbd22c607cdcabd0a05c5e5ea27 Mon Sep 17 00:00:00 2001 From: Alexander Fortin Date: Tue, 7 Jun 2016 17:35:40 +0200 Subject: [PATCH] Improve vagrant provisioner resiliency (#2252) This should make it easier to fix race conditions that might arise if box is destroyed but setup_done placeholder file is not removed properly --- virtualization/vagrant/provision.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/virtualization/vagrant/provision.sh b/virtualization/vagrant/provision.sh index 299828525c1..69414cb9200 100644 --- a/virtualization/vagrant/provision.sh +++ b/virtualization/vagrant/provision.sh @@ -38,6 +38,19 @@ HASS running => http://localhost:8123/ ' } +setup_error() { + echo '############################################################ +Something is off... maybe setup did not complete properly? +Please ensure setup did run correctly at least once. + +To run setup again: + +`rm setup_done; vagrant provision` + +############################################################' + exit 1 +} + setup() { local hass_path='/root/venv/bin/hass' local systemd_bin_path='/usr/bin/hass' @@ -63,7 +76,9 @@ setup() { } run_tests() { - systemctl stop home-assistant + if ! systemctl stop home-assistant; then + setup_error + fi source ~/venv/bin/activate rsync -a --delete \ --exclude='*.tox' \ @@ -74,7 +89,9 @@ run_tests() { } restart() { - systemctl restart home-assistant + if ! systemctl restart home-assistant; then + setup_error + fi rm $RESTART } @@ -82,7 +99,9 @@ main() { if ! [ -f $SETUP_DONE ]; then setup; fi if [ -f $RUN_TESTS ]; then run_tests; fi if [ -f $RESTART ]; then restart; fi - systemctl start home-assistant + if ! systemctl start home-assistant; then + setup_error + fi } main