Skip to content

Instantly share code, notes, and snippets.

@eberfreitas
Created November 13, 2015 13:47
Show Gist options
  • Select an option

  • Save eberfreitas/32aab76b9cd762efccab to your computer and use it in GitHub Desktop.

Select an option

Save eberfreitas/32aab76b9cd762efccab to your computer and use it in GitHub Desktop.

Revisions

  1. eberfreitas created this gist Nov 13, 2015.
    24 changes: 24 additions & 0 deletions vbox
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/bash

    VBOXPATH="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"

    case "$1" in
    "start" | "startvm")
    echo "Starting VM \"$2\"..."
    cmd="\"$VBOXPATH\" startvm $2 --type headless"
    eval $cmd
    ;;
    "getip" | "get")
    echo "Getting IP address for VM \"$2\"..."
    cmd="\"$VBOXPATH\" guestproperty get $2 /VirtualBox/GuestInfo/Net/0/V4/IP"
    eval $cmd
    ;;
    "poweroff" | "shutdown")
    echo "Shutting down VM \"$2\"..."
    cmd="\"$VBOXPATH\" controlvm $2 poweroff"
    eval $cmd
    ;;
    *)
    echo "Unknown command!"
    ;;
    esac