Created
March 5, 2015 13:17
-
-
Save sianios/155a464eb001f046df98 to your computer and use it in GitHub Desktop.
Simple bash script to manage Headless VM with VirtualBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage="Usage: ./vb.sh [option] [VM name]" | |
options=" | |
Options: | |
list List available virtual machines | |
running List running virtual machines | |
start Start virtual machine | |
stop Send shutdown signal to OS to shutdown machine | |
poweroff Shutdown machine like pulling the plug | |
save Save state of running virtual machine | |
reset Send a restart signal to OS | |
" | |
case $1 in | |
list) VBoxManage list vms ;; | |
running) VBoxManage list runningvms ;; | |
start) VBoxHeadless -startvm $2 & ;; | |
stop) VBoxManage controlvm $2 acpipowerbutton ;; | |
poweroff) VBoxManage controlvm $2 poweroff ;; | |
save) VBoxManage controlvm $2 savestate ;; | |
reset) VBoxManage controlvm $2 reset ;; | |
*) echo -e ""$usage" \n" "$options" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment