Koozali.org: home of the SME Server

VirtualBox 4 - Automatically Start Virtual Machine

Offline Graham

  • ****
  • 105
  • +0/-0
VirtualBox 4 - Automatically Start Virtual Machine
« on: February 06, 2012, 09:54:07 PM »
I've setup VirtualBox on SME Server Beta 8 but when it comes to the Automatically Start Virtual Machine section it stops making sense.

http://wiki.contribs.org/VirtualBox_4.0_on_SME_Server_v8_beta_6

It says "Edit your vbox file on /etc/sysconfig/" fair enough but /etc/sysconfig/vbox doesn't exist should it?

Also it then goes on to say "Edit your vbox file located on /etc/init.d/" this doesn't tell you what file to edit?

Any ideas how to set this up?

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: VirtualBox 4 - Automatically Start Virtual Machine
« Reply #1 on: February 07, 2012, 01:51:10 PM »
It says "Edit your vbox file on /etc/sysconfig/" fair enough but /etc/sysconfig/vbox doesn't exist should it?
The commands as shown will *create* /etc/sysconfig/vbox.  If it doesn't exist, I'd go ahead and create it.

Note that the argument listed after "VBOX_AUTOSTART" probably has to match the name of the virtual machine you created in earlier steps.

Also it then goes on to say "Edit your vbox file located on /etc/init.d/" this doesn't tell you what file to edit?
If the file /etc/init.d/vbox does not exist, I'd try creating it containing the content shown in the wiki.

You can create it using nano /etc/init.d/vbox

(Actually, when creating both files I would use nano -w /path/to/file - adding the "-w" to make sure that none of the input lines get wrapped when you paste them in from the wiki).

[caveat]I have never installed vbox[/caveat]

Offline Graham

  • ****
  • 105
  • +0/-0
Re: VirtualBox 4 - Automatically Start Virtual Machine
« Reply #2 on: February 07, 2012, 02:01:38 PM »
Doesn't the file also need to be in one of the rc#.d?

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: VirtualBox 4 - Automatically Start Virtual Machine
« Reply #3 on: February 09, 2012, 01:33:36 PM »
Doesn't the file also need to be in one of the rc#.d?
I would think so -- but since the wiki wants it in /etc/init.d, I'd start by putting it there, rebooting to see what happens, then fixing any subsequent problems.

When I want to automatically start custom apps on SME, I add them to /etc/e-smith/events/local as described here so that they run after all other startup services, connections, etc.

I suspect that the technically correct placement for /etc/init.d/vbox on a "normal" CentOS box booting to runlevel 7 (as the SME seems to do based on who -r) would be:
1) create /etc/rc.d/init.d/vbox with the content shown in the wiki
2) make it executable with chmod +x /etc/rc.d/init.d/vbox
2) create a symlink in /etc/rc.d/rc7.d using
cd /etc/rc.d/rc7.d
ln -s ../init.d/vbox S99vbox

(Note that SME has some more options that integrate this process with the config db -- allowing you to enable and disable services using a command like 'config setprop vbox enabled'.  Read more at http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual#Run-level_7_and_the_e-smith-service_wrapper)

[guess]
If you effect the auto-startup by creating /etc/rc.d/rc7.d/S99vbox, you probably need to add a "Kxxvbox" in either /etc/rc.d/rc0.d or /etc/rc.d/rc6.d to get vbox to shutdown politely.  Choose "xx" so that your script sorts alphabetically before any services that vbox is dependant on - 'K00vbox'

If you create a script for auto-start in /etc/e-smith/events/local, you would also want to add scripts to /etc/e-smith/events/halt and /etc/e-smith/events/reboot to generate polite shutdowns.
[/guess]