#! /bin/bash # # rc This file is responsible for starting/stopping # services when the runlevel changes. # # Now find out what the current and what the previous runlevel are. argv1="$1" set `/sbin/runlevel` runlevel=$2 previous=$1 export runlevel previous echo -n "Starting rc (runlevel $runlevel): " >> /var/log/boottime.log date >> /var/log/boottime.log . /etc/init.d/functions # See if we want to be in user confirmation mode if [ "$previous" = "N" ]; then if [ -f /var/run/confirm ] \ || grep -i confirm /proc/cmdline >/dev/null ; then rm -f /var/run/confirm CONFIRM=yes export CONFIRM echo $"Entering interactive startup" else echo $"Entering non-interactive startup" fi fi # Get first argument. Set new runlevel to this argument. [ -n "$argv1" ] && runlevel="$argv1" # Is there an rc directory for this new runlevel? [ -d /etc/rc$runlevel.d ] || exit 0 # First, run the KILL scripts. for i in /etc/rc$runlevel.d/K* ; do check_runlevel "$i" || continue # Check if the subsystem is already up. subsys=${i#/etc/rc$runlevel.d/K??} [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \ || continue # Bring the subsystem down. if egrep -q "(killproc |action )" $i ; then $i stop else action $"Stopping $subsys: " $i stop fi done # Now run the START scripts in parallel with serel, if available. if [ -x /usr/bin/sereld ]; then redhat_sysvinit_start fi # Othwerwise, run the START scripts as specified by legacy ordering. [ "$SEREL_BOOT" != "yes" ] && \ for i in /etc/rc$runlevel.d/S* ; do check_runlevel "$i" || continue # Check if the subsystem is already up. subsys=${i#/etc/rc$runlevel.d/S??} [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \ && continue # If we're in confirmation mode, get user confirmation if [ -n "$CONFIRM" ]; then confirm $subsys case $? in 0) :;; 2) CONFIRM=;; *) continue;; esac fi # Bring the subsystem up. if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then unset LANG unset LC_ALL exec $i start fi if egrep -q "(daemon |action )" $i 2>/dev/null \ || [ "$subsys" = "single" -o "$subsys" = "local" ]; then $i start else action $"Starting $subsys: " $i start fi done echo -n "Finishing rc: " >> /var/log/boottime.log date >> /var/log/boottime.log echo >> /var/log/boottime.log