<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.freebsdwiki.net/index.php?action=history&amp;feed=atom&amp;title=Rc.subr</id>
		<title>Rc.subr - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.freebsdwiki.net/index.php?action=history&amp;feed=atom&amp;title=Rc.subr"/>
		<link rel="alternate" type="text/html" href="http://www.freebsdwiki.net/index.php?title=Rc.subr&amp;action=history"/>
		<updated>2026-05-04T13:33:56Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://www.freebsdwiki.net/index.php?title=Rc.subr&amp;diff=6665&amp;oldid=prev</id>
		<title>Ninereasons at 20:41, 20 June 2006</title>
		<link rel="alternate" type="text/html" href="http://www.freebsdwiki.net/index.php?title=Rc.subr&amp;diff=6665&amp;oldid=prev"/>
				<updated>2006-06-20T20:41:23Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''rc.subr''' is a subroutine library that was developed primarily for the NetBSD system and imported into FreeBSD where it was further developed.  See [http://www.freebsd.org/cgi/man.cgi?query=rc.subr&amp;amp;apropos=0&amp;amp;sektion=0&amp;amp;manpath=FreeBSD+6.0-RELEASE+and+Ports&amp;amp;format=html man rc.subr] &lt;br /&gt;
&lt;br /&gt;
Under FreeBSD 4.x, you may have noticed this file being installed into ''/usr/local/etc/rc.subr'', where it was increasingly used by port-installed daemons.  Beginning in FreeBSD 5.0, this file became integral to the FreeBSD startup mechanism for both, base-installed services and port-installed services.  At the same time, the directory ''/etc/rc.d'' appeared in FreeBSD, where you will find startup scripts for all base-installed services (so that, for example, ''/etc/rc.sendmail'' disappeared, and was replaced by ''/[[etc/rc.d/sendmail]]'', which uses the ''rc.subr'' mechanism)&lt;br /&gt;
&lt;br /&gt;
Besides being a repository of some very useful and well-written functions, perhaps the chief advantage of using the file is that it ties the configuration, startup and shutdown of these daemons to /[[etc/rc.conf]] in a consistent way.  For example, unless the service has an &amp;lt;code&amp;gt;=&amp;quot;YES&amp;quot;&amp;lt;/code&amp;gt; line in ''rc.conf'', the ''start'' and ''stop'' commands have no effect.  &lt;br /&gt;
&lt;br /&gt;
[[User:Jimbo|Some folks]] don't like starting all of their services from ''/etc/rc.conf''.  ''' ''rc.subr'' ''' accommodates this preference with the prefixes, ''force'' and ''one''.&lt;br /&gt;
&lt;br /&gt;
Another significant change that this mechanism introduces is, if a startup script ends with ''.sh'', it will be loaded into the current shell (instead of a subshell); ''' ''N.B.'' ''': this means that ''if ''script.sh'' fails'', the remainder of the startup sequence will not be executed.&lt;br /&gt;
&lt;br /&gt;
Finally, a valuable improvement to service startup is better control over the order in which [[daemon]]s are started.  See [http://www.freebsd.org/cgi/man.cgi?query=rc&amp;amp;sektion=8&amp;amp;apropos=0&amp;amp;manpath=FreeBSD+6.0-RELEASE+and+Ports man rc(8)] and [http://www.freebsd.org/cgi/man.cgi?query=rcorder&amp;amp;sektion=8&amp;amp;apropos=0&amp;amp;manpath=FreeBSD+6.0-stable man rcorder(8)]&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
1. Minimal ''rc.d/'' script example, using the new ''rc.subr'' mechanism.  Most scripts require little more than this.&lt;br /&gt;
   #!/bin/sh&lt;br /&gt;
   #&lt;br /&gt;
   # PROVIDE: foo&lt;br /&gt;
   # REQUIRE: bar_service_required_to_precede_foo&lt;br /&gt;
   # BEFORE:  baz_service_requiring_foo_to_precede_it&lt;br /&gt;
   &lt;br /&gt;
   . /etc/rc.subr&lt;br /&gt;
   &lt;br /&gt;
   name=&amp;quot;foo&amp;quot;&lt;br /&gt;
   rcvar=`set_rcvar`&lt;br /&gt;
   command=&amp;quot;/usr/local/bin/foo&amp;quot;&lt;br /&gt;
   load_rc_config $name&lt;br /&gt;
   run_rc_command &amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2. Manually start and stop mysql, even though &amp;lt;code&amp;gt;mysql_enable&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;NO&amp;quot;&amp;lt;/code&amp;gt; (default) in ''rc.conf''.  &lt;br /&gt;
* Skip all failing pre-requisite &amp;quot;''required_*''&amp;quot; tests (if any).&lt;br /&gt;
 # /usr/local/etc/rc.d/mysql-server forcestart&lt;br /&gt;
 # /usr/local/etc/rc.d/mysql-server forcestop&lt;br /&gt;
* Skip only the &amp;lt;code&amp;gt;=&amp;quot;YES&amp;quot;&amp;lt;/code&amp;gt; test&lt;br /&gt;
 # /usr/local/etc/rc.d/mysql-server onestart&lt;br /&gt;
 # /usr/local/etc/rc.d/mysql-server onestop&lt;br /&gt;
&lt;br /&gt;
3. List the sequence in which all services will be started, reporting missing dependencies:&lt;br /&gt;
 # rcorder /etc/rc.d/* /usr/local/etc/rc.d/* &lt;br /&gt;
&lt;br /&gt;
[[Category:Important Config Files]]&lt;/div&gt;</summary>
		<author><name>Ninereasons</name></author>	</entry>

	</feed>