diff --git a/bin/mkvm.sh b/bin/mkvm.sh index e94e495..e31c573 100755 --- a/bin/mkvm.sh +++ b/bin/mkvm.sh @@ -91,11 +91,18 @@ CMD="$1" shift if [[ "$CMD" != "" ]]; then - lxc-execute -n "$VMNAME" -- "$CMD" "$@" - [ $KEEP -eq 0 ] && lxc-destroy -n "$VMNAME" + lxc-start -n "$VMNAME" + lxc-attach -n "$VMNAME" -- "$CMD" "$@" + if [ $KEEP -eq 0 ]; then + lxc-stop --kill "$VMNAME" + lxc-destroy -n "$VMNAME" + fi else lxc-start -n "$VMNAME" lxc-attach -n "$VMNAME" bash - [ $KEEP -eq 0 ] && lxc-stop --kill "$VMNAME" && lxc-destroy -n "$VMNAME" + if [ $KEEP -eq 0 ]; then + lxc-stop --kill "$VMNAME" + lxc-destroy -n "$VMNAME" + fi fi