From owner-freebsd-current Sat Jun 15 0:29:25 2002 Delivered-To: freebsd-current@freebsd.org Received: from mta5.snfc21.pbi.net (mta5.snfc21.pbi.net [206.13.28.241]) by hub.freebsd.org (Postfix) with ESMTP id 246D837B403; Sat, 15 Jun 2002 00:29:21 -0700 (PDT) Received: from kokeb.ambesa.net ([64.172.24.166]) by mta5.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GXQ004IIKSWCB@mta5.snfc21.pbi.net>; Sat, 15 Jun 2002 00:29:21 -0700 (PDT) Received: from kokeb.ambesa.net (tanstaafl@localhost [127.0.0.1]) by kokeb.ambesa.net (8.12.3/8.12.3) with ESMTP id g5F7Yaq6004239; Sat, 15 Jun 2002 00:34:36 -0700 (PDT envelope-from mikem@kokeb.ambesa.net) Received: (from mikem@localhost) by kokeb.ambesa.net (8.12.3/8.12.3/Submit) id g5F7Ya0U004238; Sat, 15 Jun 2002 00:34:36 -0700 (PDT envelope-from mikem) Date: Sat, 15 Jun 2002 00:34:36 -0700 From: Mike Makonnen Subject: Re: HEADS UP: rc.d is in the tree In-reply-to: <20020615011431.GG80429@wantadilla.lemis.com> To: Greg 'groggy' Lehey Cc: gordont@gnf.org, current@FreeBSD.ORG Message-id: <20020615003436.05e49755.makonnen@pacbell.net> MIME-version: 1.0 X-Mailer: Sylpheed version 0.7.0 (GTK+ 1.2.10; i386--freebsd5.0) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT References: <20020615011431.GG80429@wantadilla.lemis.com> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 15 Jun 2002 10:44:31 +0930 "Greg 'groggy' Lehey" 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