Repair rcenable(8) and rcdisable(8).
authorSascha Wildner <saw@online.de>
Sun, 26 Jul 2009 21:39:27 +0000 (23:39 +0200)
committerSascha Wildner <saw@online.de>
Sun, 26 Jul 2009 21:41:04 +0000 (23:41 +0200)
* rcenable(8) was not playing nicely with our three year old change to
  no longer depend on _enable being appended to rc variables for starting
  daemons etc. (i.e., foo_enable=yes and foo=yes both work).

* rcdisable(8) did not properly run rcstop(8) because that needs to be
  run when the variable is still set to 'yes' and not after it's been
  set to 'no'.

Noticed-by: phma on #dragonflybsd
sbin/rcrun/rcrun.sh

index 4619e4d..f5b2335 100644 (file)
@@ -140,18 +140,19 @@ disable|enable)
            elif [ `varsym -s -q rcng_$i` = "$mode" ]; then
                echo "$i is already $mode"
            else
-               vars=`(cd /etc/rc.d; sh $j rcvar) 2>/dev/null | egrep '_enable' | sed -e 's/\\$//g' | sed -e 's/=.*//g'`
+               vars=`(cd /etc/rc.d; sh $j rcvar) 2>/dev/null | grep = | sed -e 's/\\$//g' | sed -e 's/=.*//g'`
                cp /etc/rc.conf /etc/rc.conf.bak
+               if [ $arg = disable ]; then
+                   rcstop $i
+               fi
                for k in $vars; do
                    rm -f /etc/rc.conf.$$
-                   ( egrep -v "#rcrun ${k}" /etc/rc.conf; printf "${k}=${mode}\t#rcrun ${k}_enable\n" ) > /etc/rc.conf.$$
+                   ( egrep -v "# rcrun enable ${k}$" /etc/rc.conf; printf "${k}=${mode}\t# rcrun enable ${k}\n" ) > /etc/rc.conf.$$
                    mv -f /etc/rc.conf.$$ /etc/rc.conf
                    echo "added/modified: ${k}=${mode}"
                done
                if [ $arg = enable ]; then
                    rcstart $i
-               else
-                   rcstop $i
                fi
            fi
        done