]> gitweb.fluxo.info Git - scripts.git/commitdiff
Adding vbox script
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 13 Jun 2014 19:35:50 +0000 (16:35 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 13 Jun 2014 19:35:50 +0000 (16:35 -0300)
vbox [new file with mode: 0755]

diff --git a/vbox b/vbox
new file mode 100755 (executable)
index 0000000..cb9dc85
--- /dev/null
+++ b/vbox
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Simple wrapper around VBoxManage.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+COMMAND="$1"
+VM="$2"
+
+# Build options
+if [ ! -z "$VM" ]; then
+  if [ "$COMMAND" == "up" ]; then
+    OPTIONS=""
+    COMMAND="startvm"
+  elif [ "$COMMAND" == "down" ]; then
+    OPTIONS="savestate"
+    COMMAND="controlvm"
+  elif [ "$COMMAND" == "halt" ]; then
+    OPTIONS="poweroff"
+    COMMAND="controlvm"
+  fi
+elif [ "$COMMAND" == "status" ]; then
+  OPTIONS="runningvms"
+  COMMAND="list"
+else
+  echo "usage: $BASENAME <command> [vm]"
+  exit 1
+fi
+
+# Dispatch
+VBoxManage $COMMAND $VM $OPTIONS