Date: Sun, 13 Mar 2005 13:15:23 +0100 From: "Ola Theander" <ola.theander@otsystem.com> To: "'Giorgos Keramidas'" <keramida@ceid.upatras.gr> Cc: freebsd-questions@freebsd.org Subject: RE: Confused about connection between an option in rc.conf and the associated action? Message-ID: <20050313121519.WCWB23781.mxfep02.bredband.com@c0003> In-Reply-To: <20050313021330.GA81926@gothmog.gr>
next in thread | previous in thread | raw e-mail | index | archive | help
Hello Giorgos and everybody else Thank you for your answers. It clarified things a bit but there is still a few things that I don't understand. Say I want to create my own script that should run depending on the setting in rc.conf: - Do I need to parse rc.conf myself in the script or is rc.conf parsed once and for all by rcorder (or someone else) and the settings are available e.g. as environment variables? - How is my own script found and executed by the rc script? Does the rc script execute all *.sh files in the /etc/rc.d/ directory or is some other mechanism used? - Must the config string in rc.conf have any correspondence to the actual script file using it? E.g. if I add a setting test_enable="YES" my script must be named test.sh? - This last question is somewhat related to the first. Say that I don't have to parse rc.conf myself, which variable name to I test in my script for the rc.conf setting? E.g. if I have a config string in rc.conf named test_enable="YES", how do I test for this variable's value? Do I use "test_enable" == "YES" or do I use "test" == "YES", i.e. the "_enable" part may be stripped by the parser? BTW I use FreeBSD 5.3. Kind regards, Ola Theander -----Original Message----- From: Giorgos Keramidas [mailto:keramida@ceid.upatras.gr] Sent: den 13 mars 2005 03:14 To: Ola Theander Cc: freebsd-questions@freebsd.org Subject: Re: Confused about connection between an option in rc.conf and the associated action? # Redirected from freebsd-newbies to freebsd-questions. # Please do not post technical questions to freebsd-newbies. # This is what freebsd-questions is for. Followups set. On 2005-03-13 02:49, Ola Theander <ola.theander@otsystem.com> wrote: > Dear subscribers > > I'm slightly confused about enabling an option in rc.conf and the > associated action? E.g. say that I enable gateway_enable="YES" or > maybe dhcpd_enable="YES", how does FreeBSD associate this simple line > to the associated action? I've had a theory that adding e.g. > test_enable="YES" to rc.conf would trigger the execution of the file > /etc/rc.d/test.sh at boot time but it seems like this isn't how it's done. The /etc/rc script is the first "rc script" that runs. This is the one that takes care of running all the rest of the rc stuff. In pre-5.X versions of FreeBSD, the /etc/rc script called a predefined set of /etc/rc.* scripts at specific points during the startup process, delegating pieces of the work to them. In 5.3-RELEASE and later versions of FreeBSD, there is a collection of small /etc/rc.d/* scripts, that are called by /etc/rc instead of the older /etc/rc.* stuff. The specific order these scripts will have is determined at boot time, by the /sbin/rcorder utility. Each script, either one of the older /etc/rc.* stuff or the newer /etc/rc.d/* scripts, slurps in /etc/rc.conf and then checks what parts of the script are enabled to run. It is the responsibility of the specific script to check the proper rc.conf variables and act accordingly. A small example of an rc script that checks a variable and modifies its own behavior is /etc/rc.d/tmp, which contains (among other stuff): load_rc_config $name # If we do not have a writable /tmp, create a memory # filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp, # then it should already be writable). # case "${tmpmfs}" in [Yy][Ee][Ss]) ... Thus, it's not /etc/rc that checks the "tmpfs" variable from rc.conf, but the specific script that is interested in its value. Regards, Giorgos
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050313121519.WCWB23781.mxfep02.bredband.com>