Blame | Last modification | View Log | RSS feed
#! /bin/bash## rc This file is responsible for starting/stopping# services when the runlevel changes.## Original Author:# Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>#set -m# check a file to be a correct runlevel scriptcheck_runlevel (){# Check if the file exists at all.[ -x "$1" ] || return 1is_ignored_file "$1" && return 1return 0}# Now find out what the current and what the previous runlevel are.argv1="$1"set $(/sbin/runlevel)runlevel=$2previous=$1export runlevel previous. /etc/init.d/functionsexport CONSOLETYPEdo_confirm="no"if [ -f /var/run/confirm ]; thendo_confirm="yes"fiUPSTART=[ -x /sbin/initctl ] && UPSTART=yes# See if we want to be in user confirmation modeif [ "$previous" = "N" ]; thenif [ "$do_confirm" = "yes" ]; thenecho $"Entering interactive startup"elseecho $"Entering non-interactive startup"fifi# 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# Set language, vc settings once to avoid doing it for every init script# through functionsif [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" ] ; then. /etc/profile.d/lang.sh 2>/dev/nullexport LANGSH_SOURCED=1fi# First, run the KILL scripts.for i in /etc/rc$runlevel.d/K* ; do# 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 ] || continuecheck_runlevel "$i" || continue# Bring the subsystem down.[ -n "$UPSTART" ] && initctl emit --quiet stopping JOB=$subsys$i stop[ -n "$UPSTART" ] && initctl emit --quiet stopped JOB=$subsysdone# Now run the START scripts.for i in /etc/rc$runlevel.d/S* ; do# Check if the subsystem is already up.subsys=${i#/etc/rc$runlevel.d/S??}[ -f /var/lock/subsys/$subsys ] && continue[ -f /var/lock/subsys/$subsys.init ] && continuecheck_runlevel "$i" || continue# If we're in confirmation mode, get user confirmationif [ "$do_confirm" = "yes" ]; thenconfirm $subsysrc=$?if [ "$rc" = "1" ]; thencontinueelif [ "$rc" = "2" ]; thendo_confirm="no"fifiupdate_boot_stage "$subsys"# Bring the subsystem up.[ -n "$UPSTART" ] && initctl emit --quiet starting JOB=$subsysif [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; thenexport LC_ALL=Cexec $i startfi$i start[ -n "$UPSTART" ] && initctl emit --quiet started JOB=$subsysdone[ "$do_confirm" = "yes" ] && rm -f /var/run/confirmexit 0