Skip to content
Snippets Groups Projects
Commit 05d191b1 authored by Alberto LIVIO BECCARIA's avatar Alberto LIVIO BECCARIA
Browse files

Added --discard-state flag to run a snapshot-configured VM without restoring...

Added --discard-state flag to run a snapshot-configured VM without restoring the saved state (but resetting the differential disk).
This is useful for running a VM for the first time, when the init is needed, but we want the full boot.
parent 962cf136
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#############################################
# VirtualBox VM Scripts v0.11
# VirtualBox VM Scripts v0.12
# by ulisse aka A. Livio Beccaria
#
# vm-start: starts a VM
......@@ -35,7 +35,7 @@ fi
. "${SRC_DIR}/settings/${VM_ID}.settings"
# read the options (command line options override settings file values)
OPTS=`getopt -o fgir --long fullscreen,gui,no-init,no-run -n "$0" -- "$@"`
OPTS=`getopt -o fgird --long fullscreen,gui,no-init,no-run,discard-state -n "$0" -- "$@"`
eval set -- "$OPTS"
# extract options and their arguments into variables
......@@ -45,6 +45,7 @@ while true ; do
-g|--gui) FULLSCREEN="0" ; shift ;;
-r|--no-run) NO_RUN="1" ; shift ;;
-i|--no-init) NO_INIT="1"; shift ;;
-d|--discard-state) DISCARD_STATE="1"; shift ;;
--) shift ; break ;;
esac
done
......@@ -117,6 +118,12 @@ vm_start_init () {
fi
}
vm_discard_state() {
echo -n "Discard state... "
vboxmanage discardstate "${VM_NAME}"
echo "OK."
}
vm_start_run() {
# --fullscreen?
if [ "${FULLSCREEN}" == "1" ]; then
......@@ -137,6 +144,7 @@ if [ $DEBUG -eq 1 ]; then
echo "fullscreen = $FULLSCREEN"
echo "no-init = $NO_INIT"
echo "no-run = $NO_RUN"
echo "discard-state = $DISCARD_STATE"
fi
# check if vm exists
......@@ -159,6 +167,11 @@ if [ "${NO_INIT}" != "1" ]; then
vm_start_init
fi
# --discard-state?
if [ "${DISCARD_STATE}" == "1" ]; then
vm_discard_state
fi
# --no-run?
if [ "${NO_RUN}" != "1" ]; then
vm_start_run
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment