#! /bin/sh #---------------------------------------------------------------------------- # /etc/rc - resource control script # # Creation: 07.08.2001 fm # Last Update: 14.09.2003 fm # # Copyright (c) 2001-2003 Frank Meyer #---------------------------------------------------------------------------- runlevel=$1 trap "echo" 2 # catch interrupts PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin; export PATH /usr/local/bin/colecho "Running $0" gn if [ "$PREVLEVEL" = "$RUNLEVEL" ] then exit 0 fi colecho "Switching from runlevel $PREVLEVEL to $RUNLEVEL" gn curdir=/etc/rc$RUNLEVEL.d prevdir=/etc/rc$PREVLEVEL.d rex="[0-9][0-9]" if [ $RUNLEVEL = 0 -o $RUNLEVEL = 6 ] then echo "System is going down now!" | /usr/bin/wall 2>/dev/null fi #---------------------------------------------------------------------------- # previous runlevel: kill jobs #---------------------------------------------------------------------------- for i in $prevdir/K* do if [ -x "$i" ] then # don't run the kill script, if the new runlevel has a start script script=`echo $i | sed "s#$prevdir/K$rex##"` script=`eval echo "$curdir/S$rex$script"` if [ ! -f "$script" ] then $i stop fi fi done #---------------------------------------------------------------------------- # new runlevel: start jobs #---------------------------------------------------------------------------- for i in $curdir/S* do if [ -x "$i" ] then # don't run start script, if previous runlevel had a kill script script=`echo $i | sed "s#$prevdir/S$rex##"` script=`eval echo "$curdir/S$rex$script"` if [ ! -f "$script" ] then $i start fi fi done exit 0