Date: Tue, 7 Jun 2005 12:08:55 -0400 From: "J.R. Oldroyd" <fbsd@opal.com> To: Brooks Davis <brooks@one-eyed-alien.net> Cc: freebsd-rc@freebsd.org Subject: Re: Use of rcorder for local rc.d/*.sh scripts Message-ID: <20050607160855.GO37208@linwhf.opal.com> In-Reply-To: <20050607033536.GH37208@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>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
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 @@
skip="-s nostart"
[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && skip="$skip -s nojail"
+
files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null`
+# 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=""
+case ${local_startup} in
+[Nn][Oo] | '')
+ ;;
+*)
+ for dir in ${local_startup}; do
+ if [ -d "${dir}" ]; then
+ local_rc_files="${local_rc_files} ${dir}/*"
+ fi
+ done
+ ;;
+esac
+
+files=`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=1
for _rc_elem in ${files}; do
+ case "${_rc_elem}" in
+ /etc/rc.d/MOUNTDONE)
+ _rc_skip=""
+ ;;
+ esac
+ if [ -n "${_rc_skip}" ]; then
+ case "${_rc_elem}" in
+ /etc/rc.d/*)
+ continue
+ ;;
+ esac
+ fi
run_rc_script ${_rc_elem} ${_boot}
done
[-- Attachment #2 --]
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050607160855.GO37208>
