5 # $DragonFly: src/sbin/rcrun/rcrun.sh,v 1.4 2003/12/13 02:49:09 dillon Exp $
7 OS
=`sysctl -n kern.ostype`
15 case X
`varsym -s -q rcng_$i` in
17 echo "$i has already been started"
20 echo "$i has already been configured"
24 for j
in `rcorder -k $OS -o $i /etc/rc.d/*`; do
26 for k
in `rcorder -p $j`; do
30 state
=`varsym -s -q rcng_$k`
32 Xrunning
*|Xconfigured
*|Xirrelevant
*|Xdisabled
*)
35 echo "$i depends on $k, current state: $state"
42 # $j contains the last dependancy, which we run
45 echo "Unable to find keyword $i"
46 elif [ $_return = 0 ]; then
47 echo "Running $j $arg"
48 (cd /etc
/rc.d
; sh
$j $arg)
49 case X
`varsym -s -q rcng_$i` in
51 echo "$i is disabled, enable in rc.conf first or use rcforce"
54 echo "$i has failed to start"
107 dostart forcestart $@
114 j
=`rcorder -k $OS -o $i /etc/rc.d/* | tail -1`
116 echo "Unable to find keyword $i"
118 (cd /etc
/rc.d
; sh
$j stop
)
124 j
=`rcorder -k $OS -o $i /etc/rc.d/* | tail -1`
126 echo "Unable to find keyword $i"
128 (cd /etc
/rc.d
; sh
$j restart
)
133 if [ "$arg" = "enable" ]; then
139 j
=`rcorder -k $OS -o $i /etc/rc.d/* | tail -1`
141 echo "Unable to find provider id $i"
142 elif [ `varsym -s -q rcng_$i` = "$mode" ]; then
143 echo "$i is already $mode"
145 vars
=`(cd /etc/rc.d; sh $j rcvar) 2>/dev/null | egrep '_enable' | sed -e 's/\\$//g' | sed -e 's/=.*//g'`
146 cp /etc
/rc.conf
/etc
/rc.conf.bak
148 rm -f /etc
/rc.conf.$$
149 ( egrep -v "#rcrun ${k}" /etc/rc.conf; printf "${k}=${mode}\t#rcrun ${k}_enable\n" ) > /etc
/rc.conf.$$
150 mv -f /etc
/rc.conf.$$
/etc
/rc.conf
151 echo "added/modified: ${k}=${mode}"
153 if [ $arg = enable ]; then
163 j
=`rcorder -k $OS -o $i /etc/rc.d/* | tail -1`
165 echo "Unable to find provider id $i"
167 (cd /etc
/rc.d
; sh
$j rcvar
)
173 for i
in `varsym -a -s | egrep '^rcng_'`; do
178 varsym
-s rcng_
$i 2>/dev
/null || varsym
-s rcng_
$i
183 echo "$0 {start|stop|restart|rcvar|list|forcestart|faststart} <rcng_list>"