4 # The DragonFly Project. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
16 # 3. Neither the name of The DragonFly Project nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific, prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 if [ -r /etc
/defaults
/rc.conf
]; then
35 .
/etc
/defaults
/rc.conf
38 if [ -r /etc
/rc.conf
]; then
44 rcfiles
=`find /etc/rc.d -type f`
45 for d
in $local_startup; do
47 rcfiles
="$rcfiles `find $d -type f`"
50 # The last element of this list is the script that provides the target
53 rclist
=`rcorder -o $1 $rcfiles`
62 case X
`varsym -s -q rcng_$tgt` in
64 echo "$tgt has already been started"
67 echo "$tgt has already been configured"
72 for dep
in $rclist; do
74 dep_prvd_list
=`rcorder -p $dep`
75 # Because the dependency could actually provide more than one
76 # keyword, iterate it twice, first looking for a match in any
79 for dep_prvd
in $dep_prvd_list; do
80 if [ $dep_prvd = $tgt ]; then
84 if [ $need = 1 ]; then
85 for dep_prvd
in $dep_prvd_list; do
86 state
=`varsym -s -q rcng_$dep_prvd`
88 Xrunning
*|Xconfigured
*|Xirrelevant
*|Xdisabled
*)
91 echo "$tgt depends on $dep_prvd, current state: $state"
98 # $dep contains the last dependency, which we run
100 if [ X
$dep = X
]; then
101 echo "Unable to find keyword $tgt"
102 elif [ $_return = 0 ]; then
103 echo "Running $dep $arg"
105 case X
`varsym -s -q rcng_$tgt` in
107 echo "$tgt is disabled, enable in rc.conf first or use rcforce/rcone"
110 echo "$tgt has failed to start"
172 dostart forcestart $@
183 dep
=`echo "$rclist" | tail -1`
184 if [ X
$dep = X
]; then
185 echo "Unable to find keyword $tgt"
194 dep
=`echo "$rclist" | tail -1`
195 if [ X
$dep = X
]; then
196 echo "Unable to find keyword $tgt"
205 dep
=`echo "$rclist" | tail -1`
206 if [ X
$dep = X
]; then
207 echo "Unable to find keyword $tgt"
216 dep
=`echo "$rclist" | tail -1`
217 if [ X
$dep = X
]; then
218 echo "Unable to find keyword $tgt"
225 if [ "$arg" = "enable" ]; then
232 dep
=`echo "$rclist" | tail -1`
233 if [ X
$dep = X
]; then
234 echo "Unable to find provider id $tgt"
235 elif [ `varsym -s -q rcng_$tgt` = "$mode" ]; then
236 echo "$tgt is already $mode"
238 vars
=`(sh $dep rcvar) 2>/dev/null | grep = | sed -e 's/\\$//g' | sed -e 's/=.*//g'`
239 cp /etc
/rc.conf
/etc
/rc.conf.bak
240 if [ $arg = disable
]; then
244 rm -f /etc
/rc.conf.$$
245 ( egrep -v "# rcrun enable ${k}$" /etc/rc.conf; printf "${k}=${mode}\t# rcrun enable ${k}\n" ) > /etc
/rc.conf.$$
246 mv -f /etc
/rc.conf.$$
/etc
/rc.conf
247 echo "added/modified: ${k}=${mode}"
249 if [ $arg = enable ]; then
258 dep
=`echo "$rclist" | tail -1`
259 if [ X
$dep = X
]; then
260 echo "Unable to find provider id $tgt"
267 if [ "X$*" = X
]; then
268 for tgt
in `varsym -a -s | egrep '^rcng_'`; do
273 varsym
-s rcng_
$tgt 2>/dev
/null || varsym
-s rcng_
$tgt
278 echo "usage: rcrun action rcscript1 ..."
279 echo " where 'action' is one of:"
280 echo " start|stop|restart|reload|status|rcvar|list|forcestart|faststart"
281 echo " onestart|disable|enable"