# rc.d script to start Virtual Box guest.



## jsimpson (Jul 22, 2010)

Hi all,

I made a rc.d script to start and stop my virtual box guest.



```
#!/bin/sh
# REQUIRE: login
# PROVIDE: vmsd
# KEYWORD: shutdown

. /etc/rc.subr


name="vmsd"
rcvar=`set_rcvar`
start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name

vmsd_start()
{

	echo "Starting VMS machines"
	su vms -c '/usr/local/bin/VBoxHeadless -startvm fcserver'&

	
	return 1
}

vmsd_stop()
{
	echo "Saving states for all VMS machines.."
	su vms -c '/usr/local/bin/VBoxManage controlvm fcserver savestate' 
	return 1

}

#${vmsd_enable="NO"}

run_rc_command "$1"
```

I have specified 
	
	



```
vmsd_enable="YES"
```
 in my rc.conf.

For some reason, doing ./vmsd stop and ./vmsd start works perfect.

But when the machine boots it doesnt want to load the script or echo any of the messages...

Also the scripts are set with the correct permissions


----------



## gordon@ (Jul 25, 2010)

That should be


```
# REQUIRE: LOGIN
```

Case matters.


----------



## jsimpson (Jul 26, 2010)

gordon@ said:
			
		

> That should be
> 
> 
> ```
> ...



Thank you very much, i will be trying it today

Regards,
Johan


----------

