diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2012-11-17 08:46:49 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2012-11-20 13:39:25 +0100 |
commit | 25c55c77752d5026d990b491c1bd829d4c863f7f (patch) | |
tree | 0ff7de9f1a1534d78838b176235f4ecbe8bc884b | |
parent | 48e1578292ab62ff36eabc9af88419d9ee9390f5 (diff) |
If inside a screen, wait for user input to exit
-rwxr-xr-x | kvm-wrapper.sh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh index 4815f69..c31bdc7 100755 --- a/kvm-wrapper.sh +++ b/kvm-wrapper.sh @@ -18,8 +18,12 @@ function canonpath () # Exit on fail and print a nice message function fail_exit () { - echo -ne '\n\n\n' + echo -ne '\n' echo -e "$1" + [[ -n "$STY" ]] && ( + echo "Press ^D (EOF) or enter to exit" + read + ) echo "Exiting." exit 1 } @@ -500,7 +504,9 @@ function kvm_start_vm () echo $EXEC_STRING echo "" echo "" - eval $EXEC_STRING + eval "$EXEC_STRING" + + local KVM_RETURN_VALUE="$?" # Cleanup files rm -rf "$PID_FILE" @@ -510,6 +516,9 @@ function kvm_start_vm () # If drive is a lv in the main vg, deactivate the lv unprepare_disks "$KVM_DISK1" "$KVM_DISK2" "$KVM_DISK3" "$KVM_DISK4" + [[ "$KVM_RETURN_VALUE" != "0" ]] && fail_exit "Something went wrong with kvm execution, read above" + + # Exit return 0 } |