Created
March 11, 2012 09:18
-
-
Save basilevs/2015706 to your computer and use it in GitHub Desktop.
Virtal box machine as linux service
This file contains hidden or 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/sh | |
#Manages VBox machines | |
if [ $# -ne 3 ]; then | |
echo sudo -n -H -u USER $0 MACHINE SNAPSHOT {start|stop} | |
# -n - noninteractive | |
# -H - provide HOME variable (required by VBox communication link) | |
# -u - run as user (owns VM) | |
fi | |
VM="$1" | |
shift | |
SNAPSHOT="$1" | |
shift | |
case $1 in | |
start) | |
VBoxManage snapshot "$VM" restore "$SNAPSHOT" | |
VBoxManage startvm "$VM" --type headless | |
;; | |
stop) | |
VBoxManage controlvm "$VM" poweroff | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment