My goal is to have Ubuntu start and stop a headless virtualbox VM gracefully when I start and stop my host machine(Ubuntu 10.04).
This is the LSB comment header from the script (I eliminted vboxnet from "Required-Start" to reduce dependencies):
### BEGIN INIT INFO # Provides: vboxsvc # Required-Start: $local_fs $remote_fs vboxdrv # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: VirtualBox Service # Description: VirtualBox Service to startup and shutdown Virtual Machines ### END INIT INFO
As explained by Quadir I located the 'vboxsvc' in /etc/init.d/ and executed:
$sudo update-rc.d vboxsvc
This created the links for the runlevels. For example in the runlevel 2:
$ls -l /etc/rc2.d/ ... lrwxrwxrwx 1 root root 17 2010-11-03 20:02 S20vboxdrv -> ../init.d/vboxdrv lrwxrwxrwx 1 root root 25 2010-11-03 20:03 S20vboxweb-service -> ../init.d/vboxweb-service lrwxrwxrwx 1 root root 17 2010-11-11 21:43 S21vboxsvc -> ../init.d/vboxsvc ...
If I start|stop the service manually:
$sudo /etc/init.d/vboxsvx start
it works as expected.
The service doesn't appear listed if I do "service --status-all", but it shows up when I use sysv-rc-conf --list.
It doesn't start automatically when I boot the computer. On the other hand, the service stops automatically when I reboot or shutdown. For some reason when the system boots the link /etc/rc2.d/S21vboxnet is not being executed or something else is happening.
I know that Upstart is the way to do things now in Ubuntu, but SysV init is still supported, right?
EDIT: I think I'm close to solving the problem. I think that the solution has to do with having my home file system encrypted. When the init process is executing the corresponding startup scripts and tries to execute "sudo -H -u myuser VBoxManage myVirtualMachine -type vrdp > /dev/null" it doesn't have access to myVirtualMachine's data(which is at an encrypted file system) because I haven't logged in as myuser yet and, therefore, my home filesystem hasn't been mounted.