From owner-freebsd-rc@FreeBSD.ORG Tue Jun 7 16:10:56 2005 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3338416A41C; Tue, 7 Jun 2005 16:10:56 +0000 (GMT) (envelope-from jr@opal.com) Received: from smtp.vzavenue.net (smtp.vzavenue.net [66.171.59.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4703243D48; Tue, 7 Jun 2005 16:10:51 +0000 (GMT) (envelope-from jr@opal.com) Received: from linwhf.opal.com (112.79.171.66.subscriber.vzavenue.net [66.171.79.112]) by smtp.vzavenue.net (MOS 3.4.8-GR) with ESMTP id CIW18678; Tue, 7 Jun 2005 12:08:56 -0400 (EDT) Received: from ASSP-nospam (localhost [127.0.0.1]) by linwhf.opal.com (8.13.3/8.13.3) with ESMTP id j57G8tBb046195; Tue, 7 Jun 2005 12:08:55 -0400 (EDT) (envelope-from jr@opal.com) Received: from 127.0.0.1 ([127.0.0.1] helo=linwhf.opal.com) by ASSP-nospam ; 7 Jun 05 16:08:55 -0000 Received: (from jr@localhost) by linwhf.opal.com (8.13.3/8.13.3/Submit) id j57G8tGM046194; Tue, 7 Jun 2005 12:08:55 -0400 (EDT) (envelope-from jr) Date: Tue, 7 Jun 2005 12:08:55 -0400 From: "J.R. Oldroyd" To: Brooks Davis Message-ID: <20050607160855.GO37208@linwhf.opal.com> References: <20050603143803.GP886@linwhf.opal.com> <42A4CA37.1050201@FreeBSD.org> <20050606235426.GA10526@odin.ac.hmc.edu> <20050607001447.GG37208@linwhf.opal.com> <20050607003142.GD10526@odin.ac.hmc.edu> <20050607033536.GH37208@linwhf.opal.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="w7PDEPdKQumQfZlR" Content-Disposition: inline In-Reply-To: <20050607033536.GH37208@linwhf.opal.com> User-Agent: Mutt/1.4.2.1i X-Junkmail-Status: score=0/50, host=smtp.vzavenue.net Cc: freebsd-rc@freebsd.org Subject: Re: Use of rcorder for local rc.d/*.sh scripts X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2005 16:10:56 -0000 --w7PDEPdKQumQfZlR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Having slept on this, I am in two minds as to which approach is better: hacking localpkg or fixing /etc/rc to handle everything in all startup dirs. I do think that the use of a single rc script to run all rc files is probably the proper approach, even though moving to this from where we are now will require more changes. So, I offer the following solution as an alternative to the hack to localpkg. Below I: - add /etc/rc.d/MOUNTDONE a dummy script to flag the point in the list when we've completed the fs mounts - patches to /etc/rc to run the files list in two passes, once for the files in /etc/rc.d up to the MOUNTDONE point, and then a second time with the files in the local startup dirs included, this time skipping files in /etc/rc.d prior to the MOUNTDONE point In this version, I have removed the code that required local startup scripts to be named *.sh since rc.subr's run_rc_script function handles *.sh specially. So, if this approach were adopted, several changes will be needed to all local rc scripts: - any with a .sh suffix will need to be renamed from "foo.sh" to "foo" - any files like "*.sh.sample" will have to be moved elsewhere, or made non-executable - rcorder tags will need to be added to any that care about the order of their execution, and names like "000.*" can be eliminated Obviously, similar changes will be needed for /etc/rc.shutdown. -jr --- /etc/rc.d/MOUNTDONE.orig Wed Dec 31 19:00:00 1969 +++ /etc/rc.d/MOUNTDONE Tue Jun 7 11:23:01 2005 @@ -0,0 +1,12 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: MOUNTDONE +# REQUIRE: mountcritlocal mountcritremote +# BEFORE: SERVERS DAEMON LOGIN + +# This is a dummy dependency to flag when fs mounts are done +# after which local rc scripts can be merged into the rc startup +# list. --- /etc/rc.orig Thu Jun 2 09:07:12 2005 +++ /etc/rc Tue Jun 7 11:53:49 2005 @@ -72,9 +72,51 @@ =20 skip=3D"-s nostart" [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && skip=3D"$skip -s nojai= l" + files=3D`rcorder ${skip} /etc/rc.d/* 2>/dev/null` =20 +# run all startup scripts to the point where fs mounts are done +for _rc_elem in ${files}; do + case "${_rc_elem}" in + /etc/rc.d/MOUNTDONE) + break + ;; + esac + run_rc_script ${_rc_elem} ${_boot} +done + +# now look for additional startup scripts in local startup dirs +local_rc_files=3D"" +case ${local_startup} in +[Nn][Oo] | '') + ;; +*) + for dir in ${local_startup}; do + if [ -d "${dir}" ]; then + local_rc_files=3D"${local_rc_files} ${dir}/*" + fi + done + ;; +esac + +files=3D`rcorder ${skip} /etc/rc.d/* ${local_rc_files} 2>/dev/null` + +# redo the list, skipping any already done, which are files in +# /etc/rc.d prior to MOUNTDONE +_rc_skip=3D1 for _rc_elem in ${files}; do + case "${_rc_elem}" in + /etc/rc.d/MOUNTDONE) + _rc_skip=3D"" + ;; + esac + if [ -n "${_rc_skip}" ]; then + case "${_rc_elem}" in + /etc/rc.d/*) + continue + ;; + esac + fi run_rc_script ${_rc_elem} ${_boot} done =20 --w7PDEPdKQumQfZlR Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iQDVAwUBQqXGl0kkqUax7f6FAQL35gX/RhVTUa7jNlVhJnbdm7E3X4dekJJxw+gX MI39sMZ8IiisSMSHgX4YchxRwZPWFYcSW4zwaFszAMCd7U+TEQZiZFGrHBLvb1PI IgmHjL/9V3SeCh5RM6Cmpc4II2CW2L+o/zEi6Ui8RxhPqNN/CjCOo3f1LjyA7+a1 /YXKFYiAp80XbrMFHOMzmpA2BkpTtT35LZJNg/knsyMa00xDGj1ewKzg1SJpK7yl XRTRw/IqlDJbcBZ6U1wUOrR10pVXDzDN =f80C -----END PGP SIGNATURE----- --w7PDEPdKQumQfZlR--