Subject: misc/16270: rc.d script to chainload scripts outside /etc/rc.d at bootup
To: None <gnats-bugs@gnats.netbsd.org>
From: None <slink@unixbsd.org>
List: netbsd-bugs
Date: 04/09/2002 17:32:16
>Number: 16270
>Category: misc
>Synopsis: rc.d script to chainload scripts outside /etc/rc.d at bootup
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: misc-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Apr 09 08:32:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Julio Merino
>Release: NetBSD 1.5ZC
>Organization:
HispaBSD
>Environment:
System: NetBSD darkstar 1.5ZC NetBSD 1.5ZC (DARKSTAR) #3: Sat Apr 6 17:36:25 CEST 2002 root@darkstar:/home/archive/NetBSD/src/sys/arch/i386/compile/DARKSTAR i386
Architecture: i386
Machine: i386
>Description:
The following script, to be placed in /etc/rc.d/chainrcd, will
boot-up other rc.d scripts that are outside the standard
/etc/rc.d. It is useful to use pkg's scripts and others, as it
is configurable.
At startup, the scripts controlled by chainrcd will be called at
the end of the boot process, so they will have a fully configured
network and maybe several other services. (The requirement's line
could be changed)
At shutdown, it will also call those scripts so if they need to
do some work, they can effectively do it.
The script needs the following two variables in /etc/rc.conf:
chainrcd=YES
chainrcddirs="/usr/pkg/etc/rc.d /usr/X11R6/etc/rc.d /usr/local/etc/rc.d"
The first one tells the script to actually do something (it should
be set in /etc/defaults/rc.conf. The second variable is a list of
directories that will be looked for scripts.
>How-To-Repeat:
>Fix:
#!/bin/sh
# PROVIDE: mixer
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# This script chainloads scripts found in several non-standard
# directories. Note that chainrcd depends on LOGIN, so all
# chainloaded scripts will be loaded at the end of the boot
# process.
#
# The variable $rcddirs holds a list of directories (splitted by
# spaces) which should be scanned for startup files.
#
. /etc/rc.subr
name="chainrcd"
rcvar="chainrcd"
start_cmd="chainrcd_start"
stop_cmd="chainrcd_stop"
chainrcd_start()
{
scripts=""
for d in $chainrcddirs; do
if test -d $d; then
scripts="$scripts $d/*"
fi
done
files=`rcorder -s nostart $scripts`
for _rc_elem in $files; do
run_rc_script $_rc_elem start
done
}
chainrcd_stop()
{
scripts=""
for d in $chainrcddirs; do
if test -d $d; then
scripts="$scripts $d/*"
fi
done
files=`rcorder -s nostart $scripts`
for _rc_elem in $files; do
run_rc_script $_rc_elem stop
done
}
load_rc_config $name
run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted: