3 # hdw - linux /etc/init.d/rc
5 # controls switching of runlevels (copied from ROCK Linux)
10 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
12 echo "** running rc script **"
14 echo "RC: Previous runlevel: $PREVLEVEL, current runlevel: $RUNLEVEL."
16 curdir=/etc/init.d/rc$RUNLEVEL.d
17 prevdir=/etc/init.d/rc$PREVLEVEL.d
20 # run the KILL scripts of the previous runlevel (if needed)
22 if ! [ $PREVLEVEL = S -o $PREVLEVEL = N ]
24 echo "RC: Leave runlevel $PREVLEVEL ..."
25 for i in $prevdir/K*; do
26 test -x "$i" || continue
27 x="`echo "$i" | sed "s,$prevdir/K..,$curdir/S??,"`"
28 [ "`echo $x`" = "$x" ] || continue ; unset x
33 echo "RC: Enter runlevel $RUNLEVEL ..."
40 echo "Sending all processes a SIGTERM (15) ..."
43 echo "Sending all processes a 2nd SIGTERM (15) ..."
46 echo "Sending all processes a SIGKILL (9) ..."
49 elif [ $RUNLEVEL = 0 -o $RUNLEVEL = 6 ]
52 # shut down the system
54 if [ $RUNLEVEL = 0 ] ; then
55 mode=halt ; else mode=reboot ; fi
56 /etc/init.d/down $mode | /sbin/btee a /var/log/init.old
60 # run the START scripts of the current (new) runlevel
62 for i in $curdir/S*; do
63 test -x "$i" || continue
64 x="`echo "$i" | sed "s,$curdir/S..,$prevdir/K??,"`"
65 [ "`echo $x`" = "$x" ] || continue ; unset x
70 echo "RC: The system is now in runlevel $RUNLEVEL."
72 # write EOT mark for btee