From 412db49c572eb78c03698c94ddabee5c4a6c35f4 Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Tue, 9 Sep 2014 16:35:18 +0200 Subject: [PATCH] labs: exit if ssh returns error value With this changeset, osbash host scripts abort installation over ssh if script execution in the VM returns an error. The patch has no effect on installations using VirtualBox guest-addons. Change-Id: Ibc0b297f44289cfe37e07fad1c0fcef1a30abfb2 --- labs/lib/osbash/functions.host | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/labs/lib/osbash/functions.host b/labs/lib/osbash/functions.host index d50266d3..932eaa2d 100644 --- a/labs/lib/osbash/functions.host +++ b/labs/lib/osbash/functions.host @@ -127,7 +127,16 @@ function ssh_exec_script { local prefix=$(get_next_prefix "$LOG_DIR" "auto") local log_path=$LOG_DIR/${prefix}_${script_name}.auto - vm_ssh "$ssh_port" "bash $remote_path && rm -vf $remote_path" > "$log_path" 2>&1 + local rc=0 + vm_ssh "$ssh_port" "bash $remote_path && rm -vf $remote_path" \ + > "$log_path" 2>&1 || rc=$? + if [ $rc -ne 0 ]; then + echo >&2 + echo "ERROR: ssh returned status $rc for $remote_path" | + tee >&2 -a "$LOG_DIR/error.log" + # kill osbash host scripts + kill -- -$$ + fi echo -en "\n$(date) done" }