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"
93 echo "$i has failed to start"
146 dostart forcestart $@
154 j=`echo "$rclist" | tail -1`
156 echo "Unable to find keyword $i"
165 j=`echo "$rclist" | tail -1`
167 echo "Unable to find keyword $i"
174 if [ "$arg" = "enable" ]; then
181 j=`echo "$rclist" | tail -1`
183 echo "Unable to find provider id $i"
184 elif [ `varsym -s -q rcng_$i` = "$mode" ]; then
185 echo "$i is already $mode"
187 vars=`(sh $j rcvar) 2>/dev/null | grep = | sed -e 's/\\$//g' | sed -e 's/=.*//g'`
188 cp /etc/rc.conf /etc/rc.conf.bak
189 if [ $arg = disable ]; then
193 rm -f /etc/rc.conf.$$
194 ( egrep -v "# rcrun enable ${k}$" /etc/rc.conf; printf "${k}=${mode}\t# rcrun enable ${k}\n" ) > /etc/rc.conf.$$
195 mv -f /etc/rc.conf.$$ /etc/rc.conf
196 echo "added/modified: ${k}=${mode}"
198 if [ $arg = enable ]; then
207 j=`echo "$rclist" | tail -1`
209 echo "Unable to find provider id $i"
216 if [ "X$*" = X ]; then
217 for i in `varsym -a -s | egrep '^rcng_'`; do
222 varsym -s rcng_$i 2>/dev/null || varsym -s rcng_$i
227 echo "usage: rcrun start|stop|restart|rcvar|list|forcestart|faststart|disable|enable"