From owner-freebsd-questions@FreeBSD.ORG Sun Mar 13 12:15:22 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E5EB16A4CE for ; Sun, 13 Mar 2005 12:15:22 +0000 (GMT) Received: from mxfep02.bredband.com (mxfep02.bredband.com [195.54.107.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5115943D5C for ; Sun, 13 Mar 2005 12:15:20 +0000 (GMT) (envelope-from ola.theander@otsystem.com) Received: from c0003 ([82.182.185.144] [82.182.185.144]) by mxfep02.bredband.com with ESMTP id <20050313121519.WCWB23781.mxfep02.bredband.com@c0003>; Sun, 13 Mar 2005 13:15:19 +0100 From: "Ola Theander" To: "'Giorgos Keramidas'" Date: Sun, 13 Mar 2005 13:15:23 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-Reply-To: <20050313021330.GA81926@gothmog.gr> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 thread-index: AcUncbwRlw0/ZCy9QHa45ILbMKkXCwAUnzEw Message-Id: <20050313121519.WCWB23781.mxfep02.bredband.com@c0003> cc: freebsd-questions@freebsd.org Subject: RE: Confused about connection between an option in rc.conf and the associated action? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Mar 2005 12:15:22 -0000 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 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