Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jun 2002 00:34:36 -0700
From:      Mike Makonnen <makonnen@pacbell.net>
To:        Greg 'groggy' Lehey <grog@FreeBSD.ORG>
Cc:        gordont@gnf.org, current@FreeBSD.ORG
Subject:   Re: HEADS UP: rc.d is in the tree
Message-ID:  <20020615003436.05e49755.makonnen@pacbell.net>
In-Reply-To: <20020615011431.GG80429@wantadilla.lemis.com>
References:  <Pine.LNX.4.44.0206131534350.28471-100000@smtp.gnf.org> <20020615011431.GG80429@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 15 Jun 2002 10:44:31 +0930
"Greg 'groggy' Lehey" <grog@FreeBSD.ORG> wrote:

> On Thursday, 13 June 2002 at 15:37:55 -0700, Gordon Tetlow wrote:
> > I've imported the excellent work by Mike Makonnen into the tree.
> 
> Can you summarize what the differences are?

o Instead of a few monolithic scripts in /etc there are many task oriented
   scripts in /etc/rc.d
o Dynamic ordering of boot scripts performed at boot
o Ability to run a daemon in a jailed environment as a non-privileged user
o common subroutines to make scripts shorter and easier to maintain
o If necessary, service specific knobs in /etc/rc.conf.d/

Basically, the scripts /etc/rc* scripts have been broken down into individual
scripts, each one doing one specific task**. In addition the dependency
ordering of the scripts is performed at boot time, so if you have local scripts
that you want executed at boot time, it's just a matter of writing up the script,
defining what services it should follow (i.e- after local disks have been mounted),
and then putting it
in /etc/rc.d/. There's a file: /etc/rc.subr, which is intended to make your scripts
as short as possible. It contains common subroutines that are useful in writing
scripts. Here's a quick introduction:

#!/bin/sh
#

. /etc/rc.subr

# PROVIDE: fooservice
# REQUIRE: barservice mountcritlocal
# KEYWORD: FreeBSD

name="foo"
rcvar=`set_rcvar`
command="/usr/bin/foo"
required_files="/etc/foo.conf"

load_rc_config $name
run_rc_command "$1"

Given this script, the routines in rc.subr will do the following:
o check rc.conf and /etc/rc.conf.d/foo to make sure 'foo_enable' is set.
o pull in the correct path to the command if 'foo_command' is specified,
   and make sure it is executable
o check that the required file /etc/foo.conf exists
o pull in any command line options specified in the 'foo_flags' variable
o if the appropriate variables are defined, start foo in a jail as a non-privileged user.
o tell you whether foo is already started
o tell you what pid foo is using
o let you start foo
o let you stop all instances of foo
o and some more that I can't think of right now

IMO the functionality you get for just those 11 lines is well worth the small effort
required in readjusting to this new scheme. If what you want to do requires
a little more customization, then you can also define custom start/stop/etc...
routines that will be executed instead of the default one.

Having said that, there is remarkably little to adjust to. Baring any
bugs in the scripts, switching on rcng should not break anything. 
I have tried to include temporary compatibility shims to ensure that.
I had intended to remove them before 5.0-RELEASE, but they should
probably be marked as deprecated and instead removed in 6.0-RELEASE.


Cheers,
Mike Makonnen

** Most scripts do one specific task, but there are exceptions. It is
acceptable to do more than one task if they are closely related: for
example: /etc/rc.d/sendmail


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020615003436.05e49755.makonnen>