Use of rcorder for local rc.d/*.sh scripts
J.R. Oldroyd
fbsd at opal.com
Tue Jun 7 16:10:56 GMT 2005
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 390 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20050607/41828190/attachment.bin
More information about the freebsd-rc
mailing list