Subject: Re: rc local [patches]
To: Thierry Laronde <tlaronde@polynum.com>
From: Greg A. Woods <woods@planix.com>
List: tech-userlevel
Date: 03/18/2007 19:43:42
--pgp-sign-Multipart_Sun_Mar_18_19:43:38_2007-1
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

At Sun, 18 Mar 2007 15:08:14 +0100,
tlaronde@polynum.com wrote:
>=20
> At the moment, the comments in /etc/rc.local do not emphasize the fact
> that local daemons launched via this file will be launched when
> /etc/rc.d/local is called with the start action, that is not mandatorily
> at the better time for these daemons.

I don't quite agree, but I did make the following change to my
/etc/rc.local some time ago:

Index: rc.local
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/master/m-NetBSD/main/src/etc/rc.local,v
retrieving revision 1.29
diff -u -r1.29 rc.local
--- rc.local	7 Oct 2000 00:22:44 -0000	1.29
+++ rc.local	18 Mar 2007 23:37:31 -0000
@@ -1,22 +1,23 @@
 #	$NetBSD: rc.local,v 1.29 2000/10/07 00:22:44 hubertf Exp $
 #	originally from: @(#)rc.local	8.3 (Berkeley) 4/28/94
 #
-# This file is (nearly) the last thing invoked by /etc/rc during a
-# normal boot, via /etc/rc.d/local.
+#	/etc/rc.local
+#
+# This script is (nearly) the last thing executed by /etc/rc during a
+# normal boot, via "/etc/rc.d/local start".
 #
 # It is intended to be edited locally to add site-specific boot-time
 # actions, such as starting locally installed daemons.
 #
-# An alternative option is to create site-specific /etc/rc.d scripts.
+# A better alternative is to create site-specific /etc/rc.d scripts.
+# which will be invoked with the "start" parameter on boot.
+#
+# See rc(8)
 #
=20
 echo -n 'starting local daemons:'
=20
-# Add your local daemons here.
+# Start your local daemons here.
 #
=20
-#if [ -f /usr/pkg/etc/rc.d/apache ]; then
-#	/usr/pkg/etc/rc.d/apache start
-#fi
-
 echo '.'



> Furthermore, the sibling script /etc/rc.shutdown.local is not
> advertised, while this is the script invoked when /etc/rc.d/local is
> called with the stop action (i.e., for example, by shutdown(8)). It is
> hence the natural place to put clean stopping actions for services
> launched in /etc/rc.local.

I've been using something like this for a long time now myself:

Index: rc.shutdown.local
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: rc.shutdown.local
diff -N rc.shutdown.local
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ rc.shutdown.local	18 Mar 2007 23:37:19 -0000
@@ -0,0 +1,22 @@
+#	$NetBSD$
+#
+#	/etc/rc.shutdown.local
+#
+# This script is (nearly) the last thing executed by /etc/rc during a
+# normal shutdown, via "/etc/rc.d/local stop".
+#
+# It is intended to be edited locally to add site-specific shutdown
+# actions, such as stopping locally installed daemons.
+#
+# A better alternative is to create site-specific /etc/rc.d scripts
+# which will be invoked with the "stop" parameter on shutdown.
+#
+# See rc(8)
+#
+
+echo -n 'stopping local daemons:'
+
+# kill your local daemons here.
+#
+
+echo '.'

> But a better practice for daemons is to have
> rc.d compliant scripts.

Indeed.

> Hence putting additional services in /etc/rc.d/ is perhaps not the best
> maintenance option:
> 	1) postinstall(8) may suppress scripts in /etc/rc.d/ or an upgrade
> 	may add scripts there. What if a local addition happens to provide
> 	such a named script?

So sad for the admin who did the upgrade without checking first for
local system changes.  :-)

BTW, I've found it very useful to move the base system /etc/rc.d scripts
and their associated machinery from etc.tgz to base.tgz and to get rid
of the subsequently unnecessary postinsall step.  I don't consider the
base rc.d scripts to be locally modifiable.

--=20
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>

--pgp-sign-Multipart_Sun_Mar_18_19:43:38_2007-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: m8Kolft+HKH1umL0FHoYUWEAc5TMtQHF

iQA/AwUBRf3OrWZ9cbd4v/R/EQIWowCbB3LU6d5DZMM89yddrKm9z2XE7ioAoLph
DLONZ1rzGXUhrYVRWXiJRKJF
=9Alh
-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Sun_Mar_18_19:43:38_2007-1--