Skip to content

Instantly share code, notes, and snippets.

@basilevs
Created March 11, 2012 09:18
Show Gist options
  • Save basilevs/2015706 to your computer and use it in GitHub Desktop.
Save basilevs/2015706 to your computer and use it in GitHub Desktop.
Virtal box machine as linux service
#!/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