The Booting Process

Daan Vreeken [PA4DAN] Danovitsch at Vitsch.net
Wed Dec 24 15:46:33 PST 2003


On Thursday 25 December 2003 00:25, gffds fsdff wrote:
> Is there a way, when booting, to have an application launch?
> Ex:
> exec /usr/servers/bots/zDSBot3/zDSBot3 &
Have a look at /usr/local/etc/rc.d
All scripts that are executable and end in ".sh" in that directory get 
executed at boot-time. You could create your own scripts in that directory 
that starts your application.

On boot the scripts are executed with the first agrument being "start". On 
shutdown the scripts are executed with "stop" as first argument. By checking 
the argument in your script you can determine if you should start the 
application or not. (Don't start it at shutdown :)

A simple rc.d-script could look something like this :
--- cut here ---
#!/bin/sh
case "$1" in
start)
	/some/dir/some-app && echo -n ' some-app'
        ;;
stop)
        ;;
*)
        echo "Usage: `basename $0` {start|stop}" >&2
        ;;
esac
exit 0
--- cut here ---

The "echo -n" line is the output you see when you boot your system after :
"Local package initialization :"
This only works on applications that daemonize (dissapear into the background 
when you start them). If your program doesn't daemonize, you should start it 
with an "&" sign behind it...

grtz,
Daan


More information about the freebsd-questions mailing list