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
This commit is contained in:
Alexander Fortin 2016-06-07 17:35:40 +02:00 committed by Paulus Schoutsen
parent e29459a1ae
commit fff413e04e

View File

@ -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