rc.conf and starting scripts

Jerry McAllister jerrymc at msu.edu
Mon Mar 2 07:56:00 PST 2009


On Sun, Mar 01, 2009 at 07:14:17PM -0800, gahn wrote:

> 
> Hi all:
> 
> I have some starting scripts under some other directories other 
> than /etc/rc.d. How could I utilize the rc.conf file to start them 
> when the system boots up?
> 
> The default location for rc.conf is /etc/rc.d only and the 
> knob "local_startup=/usr/local/etc/rc.d" doesn't seem to be working 
> for me for some reasons

The way the question is put implies some possible misunderstanding
about how rc.conf works.   /etc/rc.conf itself is not executed.  It
is read up by the various scripts in etc/rc.d and /usr/local/etc/rc.d
to get values for constants that are defined there.   Some of those
constants are things like  linux_enable="YES" or lpd_enable="YES" 
or  hostname="fred.cheeze.org"  and many other possible things.   
the /etc/rc.conf files does nothing active.  It just sets there like
a bunch of passive data waiting to be looked at.

The rc system goes through the rc.d directories and, according to its
rules checks the script files in those directories and executes those 
scripts that merit execution in an order determined by its protocol.  
It used to be strictly alphabetical, but is more sophisticated now.  
See  man rc  and  man rcorder.

The scripts read up /etc/rc.conf and check for constants that interest
them, such as one to enable or run something.   If the file name 
ends in 'd', the convention is that it is a daemon.   But other 
things could be run to check stuff or set up some files, or whatever.
Besides telling a script to run or exit without doing anything, the 
constants also set conditions for things, such as that hostname setting.    

But, it is up to the scripts - most or all in one of the rc.d directories -
to do anything about what is in /etc/rc.conf.  Just putting something in
the rc.conf file does nothing.   One or more of the scripts are what looks 
for the stuff you put in rc.conf and does/do all the work.

The scripts in the rc.d directories have to have execute permission.
There is a protocol set up for them to determine at which point in
the boot process they run (most can also be run manually after the
system is up, though doing them out of order can produce unpleasant
results in some cases).     

So, put your script in /usr/local/etc/rc.d.   Include the appropriate
protocol in the script (see man rc.d, man rc.conf and other related
man pages) and make sure it reads /etc/rc.conf if it needs constants
set or needs to decide whether or not to start something.

////jerry


>       
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list