Upstart and Virtualbox

Upstart script for starting and stopping Virtualbox machines. This goes into /etc/init/vbox-agila-ledare.conf (which could be paremetrized, look this up in the upstart cookbook).

# Upstart receipt for starting Virtualbox machines after reboot
description "VM for"
author "Fredrik Wendt"

start on start-vbox-machines
stop on runlevel [016]

console output

pre-stop script
  su vbox -c "VBoxManage controlvm agila-ledare savestate"
end script

  exec su vbox -c "VBoxHeadless --startvm agila-ledare"
end script