Date: Mon, 14 Mar 2005 23:06:54 +0100 From: Jose M Rodriguez <josemi@freebsd.jazztel.es> To: current@freebsd.org Subject: rcNG changes/aditions Message-ID: <200503142306.54642.freebsd@redesjm.local>
next in thread | raw e-mail | index | archive | help
--Boundary-00=_+rgNChGD7FkTmrV
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
I'll glad to know if this is of interest:
update to PR conf/75137 (sound modules): I rework this adding support
for preloaded modules to /etc/rc.subr
update to PR conf/74006 (named minor fixes): Fix a typo and umount dev
in chroot in post_stop works
--
josemi
--Boundary-00=_+rgNChGD7FkTmrV
Content-Type: text/x-diff;
charset="us-ascii";
name="patch-rcNG"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch-rcNG"
--- /usr/RELENG_5/src/etc/rc.subr Mon Jan 17 12:51:00 2005
+++ etc/rc.subr Mon Mar 14 00:01:34 2005
@@ -319,6 +319,23 @@
}
#
+# preload_modules module [...]
+# Try to kldload the given modules if not loaded.
+# Return 0 on success, kldload error otherwise.
+preload_modules()
+{
+ while [ $# -ge 1 ]; do
+ if ! /sbin/kldstat -n $1 > /dev/null 2>&1; then
+ /sbin/kldload $1
+ _return=$?
+ [ ${_return} -ne 0 ] && return ${_return}
+ fi
+ shift
+ done
+ return 0
+}
+
+#
# run_rc_command argument
# Search for argument in the list of supported commands, which is:
# "start stop restart rcvar status poll ${extra_commands}"
@@ -381,6 +398,9 @@
# to run the chrooted ${command} with.
# Requires /usr to be mounted.
#
+# ${name}_modules n If set, try to load the given modules before
+# running the default (re)start command.
+#
# ${rc_arg}_cmd n If set, use this as the method when invoked;
# Otherwise, use default command (see below)
#
@@ -633,6 +653,16 @@
fi
fi
done
+ # try to load ${name}_modules
+ #
+ eval "_modules=\$${name}_modules"
+ if [ -n "${_modules}" ]; then
+ debug "run_rc_command: kldload ${_modules}."
+ eval "preload_modules ${_modules}"
+ _return=$?
+ [ $_return -ne 0 ] && [ -z "$rc_force" ] &&
+ return 1
+ fi
# if the precmd failed and force
# isn't set, exit
--- /usr/RELENG_5/src/etc/rc.d/mixer Sun Oct 10 11:50:53 2004
+++ etc/rc.d/mixer Mon Mar 14 00:02:08 2005
@@ -81,6 +81,10 @@
{
local mixer
+ if [ -n "${mixer_modules}" ]; then
+ eval "preload_modules ${mixer_modules}"
+ fi
+
for mixer in `list_mixers`; do
mixer_restore ${mixer}
done
--- /usr/RELENG_5/src/etc/rc.d/named Sun Oct 10 11:50:53 2004
+++ etc/rc.d/named Mon Mar 14 00:01:56 2005
@@ -14,6 +14,7 @@
rcvar=`set_rcvar`
start_precmd="named_precmd"
start_postcmd="make_symlinks"
+stop_postcmd="named_postcmd"
required_dirs="$named_chrootdir" # if it is set, it must exist
extra_commands="reload"
@@ -30,36 +31,16 @@
{
# Create (or update) the chroot directory structure
#
- if [ -f /etc/mtree/BIND.chroot.dist ]; then
- mtree -deU -f /etc/mtree/BIND.chroot.dist \
+ if [ -f ${named_chroot_mtree:=/etc/mtree/BIND.chroot.dist} ]; then
+ mtree -deU -f ${named_chroot_mtree} \
-p ${named_chrootdir}
else
- warn "/etc/mtree/BIND.chroot.dist missing,"
+ warn "${named_chroot_mtree} missing,"
warn "chroot directory structure not updated"
fi
# Create /etc/namedb symlink
- #
- if [ ! -L /etc/namedb ]; then
- if [ -d /etc/namedb ]; then
- warn "named chroot: /etc/namedb is a directory!"
- elif [ -e /etc/namedb ]; then
- warn "named chroot: /etc/namedb exists!"
- else
- ln -s ${named_chrootdir}/etc/namedb /etc/namedb
- fi
- fi
-
- # Mount a devfs in the chroot directory if needed
- #
- if [ ! -c ${named_chrootdir}/dev/random -o \
- ! -c ${named_chrootdir}/dev/null ]; then
- umount ${named_chrootdir}/dev 2>/dev/null
- mount_devfs devfs ${named_chrootdir}/dev
- fi
- devfs -m ${named_chrootdir}/dev rule apply hide
- devfs -m ${named_chrootdir}/dev rule apply path null unhide
- devfs -m ${named_chrootdir}/dev rule apply path random unhide
+ # this must be a mergemaster task
# Copy local timezone information if it is not up to date.
#
@@ -87,6 +68,16 @@
rc_flags="$rc_flags -t $named_chrootdir"
confgen_chroot="-t${named_chrootdir} -u bind"
checkyesno named_chroot_autoupdate && chroot_autoupdate
+ # Mount a devfs in the chroot directory if needed
+ #
+ if [ ! -c ${named_chrootdir}/dev/random -o \
+ ! -c ${named_chrootdir}/dev/null ]; then
+ umount ${named_chrootdir}/dev 2>/dev/null
+ mount_devfs devfs ${named_chrootdir}/dev
+ fi
+ devfs -m ${named_chrootdir}/dev rule apply hide
+ devfs -m ${named_chrootdir}/dev rule apply path null unhide
+ devfs -m ${named_chrootdir}/dev rule apply path random unhide
else
named_symlink_enable=NO
fi
@@ -96,6 +87,13 @@
if [ ! -f "${named_chrootdir}/etc/namedb/rndc.key" -a \
! -f "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
rndc-confgen -a -b256 ${confgen_chroot}
+ fi
+}
+
+named_postcmd() {
+ # Is the user using a sandbox?
+ if [ -n "$named_chrootdir" ]; then
+ umount ${named_chrootdir}/dev 2>/dev/null
fi
}
--Boundary-00=_+rgNChGD7FkTmrV--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503142306.54642.freebsd>
