#!/bin/sh # Begin /etc/init.d/rc # # By Jason Pearce - jason.pearce@linux.org # Modified by Gerard Beekmans - gerard@linuxfromscratch.org # print_error_msg based on ideas by Simon Perreault - nomis80@yahoo.com # #$Date: 2003-10-22 20:35:29 +0200 (Mi, 22 Okt 2003) $ #$Revision: 3339 $ # #$Log$ #Revision 1.3 2003/10/22 18:35:29 kueller #Korrektur von rechtschreibfehlern # #Revision 1.2 2003/04/07 10:22:30 kueller #Fehlermeldungen an CompuExtreme, nicht mehr an RainMaker # #Revision 1.1.1.1 2001/09/23 00:02:08 kueller #Neustart wg. Datenverlust # #Revision 1.1.1.1 2001/08/08 10:02:32 kueller #sysvinit addons # # source /etc/init.d/functions print_error_msg() { echo $FAILURE echo "Sie sollten diese Fehlermeldung niemals sehen" echo "Sie bedeutet, das ein unvorhergesehener Fehler" echo "Aufgetreten ist." echo "Das Subscript $i ist hat sich mit dem Returnwert" echo "$error_value beendet." echo "Bitte melden sie den Fehler der Fa. CompuExtreme" $NORMAL echo } # Un-comment the following for debugging. # debug=echo # # Start script or program. # startup() { case "$1" in *.sh) $debug sh "$@" ;; *) $debug "$@" ;; esac } # Ignore CTRL-C only in this shell, so we can interrupt subprocesses. trap ":" INT QUIT TSTP # Set onlcr to avoid staircase effect. stty onlcr 0>&1 # Now find out what the current and what the previous runlevel are. runlevel=$RUNLEVEL # Get first argument. Set new runlevel to this argument. [ "$1" != "" ] && runlevel=$1 if [ "$runlevel" = "" ] then echo "Usage: $0 " >&2 exit 1 fi previous=$PREVLEVEL [ "$previous" = "" ] && previous=N export runlevel previous # Is there an rc directory for this new runlevel? if [ -d /etc/init.d/rc$runlevel.d ] then # First, run the KILL scripts for this runlevel. if [ $previous != N ] then for i in /etc/init.d/rc$runlevel.d/K* do [ ! -f $i ] && continue suffix=${i#/etc/init.d/rc$runlevel.d/K[0-9][0-9]} previous_start=/etc/init.d/rc$previous.d/S[0-9][0-9]$suffix sysinit_start=/etc/init.d/rcS.d/S[0-9][0-9]$suffix # Stop the service if there is a start script # in the previous run level. [ ! -f $previous_start ] && [ ! -f $sysinit_start ] && continue startup $i stop error_value=$? if [ $error_value != 0 ] then print_error_msg fi done fi # Now run the START scripts for this runlevel. for i in /etc/init.d/rc$runlevel.d/S* do [ ! -f $i ] && continue if [ $previous != N ] then # Find start script in previous runlevel and # stop script in this runlevel. suffix=${i#/etc/init.d/rc$runlevel.d/S[0-9][0-9]} stop=/etc/init.d/rc$runlevel.d/K[0-9][0-9]$suffix previous_start=/etc/init.d/rc$previous.d/S[0-9][0-9]$suffix # If there is a start script in the previous # level # and _no_ stop script in this level, we don't # have to re-start the service. [ -f $previous_start ] && [ ! -f $stop ] && continue fi case "$runlevel" in 0|6) startup $i stop error_value=$? if [ $error_value != 0 ] then print_error_msg fi ;; *) startup $i start error_value=$? if [ $error_value != 0 ] then print_error_msg fi ;; esac done fi # End /etc/init.d/rc