From ac1a57d96993466d38a2e87edcbcd1e5501b8c54 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Sun, 11 Feb 2018 17:01:26 +0100 Subject: [PATCH] Make provisioning script stop immediately on errors By default, bash will ignore any failing commands and happily proceed to execute the next ones. This is usually not the behavior the we want in provisioning script (or ever in scripts, actually): if one step of the provisioning fails, it doesn't make much sense to proceed with the following ones. This simple patch uses `set -e` to ask bash to abort the whole script if any command within it fails, leading to outputs that are easier to parse since the commands following a failing one will usually fail also, hiding the root cause. --- provisioning/bootstrap.sh | 3 +++ provisioning/prepare_django.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index 69bbcf4c..cb6917a7 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -1,5 +1,8 @@ #!/bin/sh +# Stop if an error is encountered +set -e + # Configuration de la base de données. Le mot de passe est constant car c'est # pour une installation de dév locale qui ne sera accessible que depuis la # machine virtuelle. diff --git a/provisioning/prepare_django.sh b/provisioning/prepare_django.sh index 1818a0cd..891108e8 100644 --- a/provisioning/prepare_django.sh +++ b/provisioning/prepare_django.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Stop if an error is encountered. +set -e + python manage.py migrate python manage.py loaddata gestion sites articles python manage.py loaddevdata