Is it possible to run a "startup" script when booting into single user mode? I need to be able to boot into single user mode, run my script, then reboot into multiuser mode without any human interaction.
I've done a bunch of research and can't find anything that is clear on the topic, although of course I could replace something else that does run with a wrapper that also launches my script, but I'd prefer to do it in some official way. Ideally, the solution will work in FreeBSD 6 and up, but I'm willing to accept only new versions if it just doesn't exist in the older revs.
EDIT: In response to comments, I'm actually looking to do two things, both of which are probably possible without single user mode, but it is much easier to control all the variables in single user mode if that is at all a possibility:
Grow the filesystem in a vmware installation (I've successfully used these instructions manually).
Zero the free space in all file systems (in this case it is to prepare the VM for export). Again, I don't really need single user mode for this, but it would make things easier.
Of course, these aren't really VM issues, but stuff that I'd like to be able to do in general. The fact that these systems happen to be in VMware is not particularly relevant, and I didn't want to throw people off by confusing them with the fact (some people seem to go a little nutty when virtualization is mentioned, but in most cases it doesn't make a difference).
EDIT2: Regardless of my current reasons, if anyone has any suggestions on how to do this (even hacks if there are no official ways), please post them as an answer.
FreeBSD's single user mode doesn't run anything other then what you enter for the 'shell' at the prompt. You could write something that performed what you need in plain old bourne and have it execute that, but it still requires you entering something at the CLI to perform it. You could potentially hack /sbin/init and supply that string yourself to autoexecute in single user mode..
/usr/src/sbin/init/init.c Starting around line 629, the function single_user() is what you want to modify, specifically the value of 'shell' and the section where it asks for it interactively.