Hello everyone,
I've been trying for hours and hours to figure out a way of running a VirtualBox machine when my system boots using upstart. I've been able to get it to boot successfully, but I can't seem to make upstart wait for it to close properly. Instead the Virtual Machine just gets killed, and loses all its active state. The guest is configured to immediately shutdown when it receives the acpishutdown signal from VBoxManage.
This is my upstart script:
I had tried it without my attempt at the loop, and obviously that didn't work. I also tried putting all of the pre-stop script in an external script - and that partly worked, although then upstart would hang indefinitely and I also could not re-start the Virtual Machine without first rebooting the host. So that approach went from no delay, to an infinite delay.Code:#Start Transmission's Virtual Machine on boot description "Transmission Virtual Machine" start on (local-filesystems and net-device-up IFACE=eth0) stop on runlevel [016] console log respawn respawn limit 5 10 kill timeout 20 pre-stop script exec sudo -u sean VBoxManage controlvm "Transmission Server" acpipowerbutton inactive=0 while [ "$inactive" == "0" ]; do inactive=`vboxmanage showvminfo "Transmission Server" | grep -E "No active facilities." | wc -l` sleep 0.5s done end script script exec sudo -u sean VBoxHeadless -startvm "Transmission Server" end script
This must be possible to do! How can I just tell upstart to wait for 20 seconds for the guest to turn off?



Adv Reply


Bookmarks