Notes on the etcrc.local File


Notes on the /etc/rc.local File

The resource configuration script /etc/rc.local was described earlier in this chapter simply as being obsolete. Administrators who used earlier versions of FreeBSD or certain Linux distributions will recognize this file. Its purpose is much the same as the /usr/local/etc/rc.d directoriesto provide you with a mechanism to extend the system's startup behavior by adding your own daemons or ad-hoc configuration changes.

The rc.d method described earlier in this chapter is the best way to run a daemon or perform some automated task upon startup. However, in some cases (such as mounting a remote server or starting a backup client), it's more expedient to have a place where you can simply execute a command line without worrying about the careful structure of the proper resource configuration system. That's what /etc/rc.local is for (although it doesn't exist in the default installation). You can create the file (with the proper interpreter line modeled after the other rc.* files) and put any set of shell commands into it, and it will be executed just before the rc.d scripts.

Support for rc.local is for backward-compatibility only, and it may eventually be removed from FreeBSD. To make sure your system supports it, check in /etc/rc.d for the existence of the local launch script, as excerpted in Listing 14.3.

Listing 14.3. Excerpt from /etc/rc.d/local Showing Support for /etc/rc.local

name="local" start_cmd="local_start" stop_cmd="local_stop" local_start() {         echo -n 'Starting local daemons:'         if [ -f /etc/rc.local ]; then                 . /etc/rc.local         fi         echo '.' } local_stop() {         echo -n 'Shutting down local daemons:'         if [ -f /etc/rc.shutdown.local ]; then                 . /etc/rc.shutdown.local         fi         echo '.' } load_rc_config $name run_rc_command "$1"

If this file exists, you can use rc.local to launch your ad-hoc commands at startup. If you can, though, it is still a much better idea to use the rc.d script method.




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net