diff --git a/do_preinstall.sh b/do_preinstall.sh
index 366ec9d74fbc536649227c514b78c5303261fc9b..1c34fcfbdc42e7e5ee6027a829218f0133d12d2f 100755
--- a/do_preinstall.sh
+++ b/do_preinstall.sh
@@ -28,20 +28,31 @@ then
     exit 1
 fi
 
+safe_run(){
+    $@
+    code=$?
+    if [ $code -ne 0 ]
+    then
+        echo "Error while running $1"
+        exit $code
+    fi
+}
+
+
 logfile="/var/log/`basename $0`_`date +%Y%m%d-%H%M`"
 exec &> >(tee -a "$logfile")
 
 echo "Updating eole"
-Maj-Auto
+safe_run Maj-Auto
 
 echo "Generating containers"
-gen_conteneurs
+safe_run gen_conteneurs
 
-echo "Generation de la configuration initiale"
-gen_config
+echo "Generating initial config"
+safe_run gen_config
 
 echo "Instanciating server"
-instance
+safe_run instance
 
 echo "Running diagnostic"
-diagnose -L
+safe_run diagnose -L