Last active
May 28, 2019 12:46
-
-
Save heatxsink/5103511 to your computer and use it in GitHub Desktop.
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 | |
### | |
# | |
# Wrap the weird VirtualBox commandline for headless vms | |
# | |
### | |
CMD_HEADLESS=`which VBoxHeadless`; | |
CMD_MANAGE=`which VBoxManage`; | |
if [ "$CMD_HEADLESS" = "" ]; then | |
echo "No VBoxHeadless installed"; | |
exit 1; | |
fi; | |
if [ "$CMD_MANAGE" = "" ]; then | |
echo "No VBoxManage installed"; | |
exit 1; | |
fi; | |
case "$1" in | |
on) | |
echo "Starting $2" | |
`nohup $CMD_HEADLESS -startvm $2` & | |
;; | |
off) | |
echo "Turning off $2" | |
$CMD_MANAGE controlvm $2 poweroff | |
;; | |
shutdown) | |
echo "Sending shutdown signal to $2" | |
$CMD_MANAGE controlvm $2 acpipowerbutton | |
;; | |
reset) | |
echo "Resetting $2" | |
$CMD_MANAGE controlvm $2 reset | |
;; | |
pause) | |
echo "Pausing $2" | |
$CMD_MANAGE controlvm $2 pause | |
;; | |
resume) | |
echo "Resuming $2" | |
$CMD_MANAGE controlvm $2 resume | |
;; | |
list) | |
echo "Listing all vms..." | |
$CMD_MANAGE list vms | |
;; | |
status) | |
echo "Listing all running vms ..." | |
$CMD_MANAGE list runningvms | |
;; | |
*) | |
echo "Usage: $NAME {on|off|shutdown|reset|pause|resume|status|list} [vm_name]" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment