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 . /etc/defaults/rc.conf
38 rcfiles=`find /etc/rc.d -type f`
39 for d in $local_startup; do
41 rcfiles="$rcfiles `find $d -type f`"
44 rclist=`rcorder -o $1 $rcfiles`
53 case X`varsym -s -q rcng_$i` in
55 echo "$i has already been started"
58 echo "$i has already been configured"
65 for k in `rcorder -p $j`; do
69 state=`varsym -s -q rcng_$k`
71 Xrunning*|Xconfigured*|Xirrelevant*|Xdisabled*)
74 echo "$i depends on $k, current state: $state"
81 # $j contains the last dependency, which we run
84 echo "Unable to find keyword $i"
85 elif [ $_return = 0 ]; then
86 echo "Running $j $arg"
88 case X`varsym -s -q rcng_$i` in
90 echo "$i is disabled, enable in rc.conf first or use rcforce/rcone"
93 echo "$i has failed to start"
149 dostart forcestart $@
160 j=`echo "$rclist" | tail -1`
162 echo "Unable to find keyword $i"
171 j=`echo "$rclist" | tail -1`
173 echo "Unable to find keyword $i"
180 if [ "$arg" = "enable" ]; then
187 j=`echo "$rclist" | tail -1`
189 echo "Unable to find provider id $i"
190 elif [ `varsym -s -q rcng_$i` = "$mode" ]; then
191 echo "$i is already $mode"
193 vars=`(sh $j rcvar) 2>/dev/null | grep = | sed -e 's/\\$//g' | sed -e 's/=.*//g'`
194 cp /etc/rc.conf /etc/rc.conf.bak
195 if [ $arg = disable ]; then
199 rm -f /etc/rc.conf.$$
200 ( egrep -v "# rcrun enable ${k}$" /etc/rc.conf; printf "${k}=${mode}\t# rcrun enable ${k}\n" ) > /etc/rc.conf.$$
201 mv -f /etc/rc.conf.$$ /etc/rc.conf
202 echo "added/modified: ${k}=${mode}"
204 if [ $arg = enable ]; then
213 j=`echo "$rclist" | tail -1`
215 echo "Unable to find provider id $i"
222 if [ "X$*" = X ]; then
223 for i in `varsym -a -s | egrep '^rcng_'`; do
228 varsym -s rcng_$i 2>/dev/null || varsym -s rcng_$i
233 echo "usage: rcrun action rcscript1 ..."
234 echo " where 'action' is one of:"
235 echo " start|stop|restart|rcvar|list|forcestart|faststart|onestart"
236 echo " disable|enable"