#!/bin/sh
#
#    Copyright (c) 1996-2000 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    Runlevel control script.
#

# Find out what the current and what the previous runlevel are.
argv1="$1"
set `/sbin/runlevel`
runlevel=$2
previous=$1
export runlevel previous

# Get first argument. Set new runlevel to this argument.

[ "$1" != "" ] && runlevel="$argv1"

if [ -d /etc/rc.d/rc$runlevel.d ]; then

	#  First, run the KILL scripts.

	for i in /etc/rc.d/rc$runlevel.d/K*; do
		# Check if the script is there.
		[ ! -f $i ] && continue

		# Bring the subsystem down.
		$i stop
	done

	#  Now run the START scripts.

	for i in /etc/rc.d/rc$runlevel.d/S*; do
		# Check if the script is there.
		[ ! -f $i ] && continue

		# Bring the subsystem up.
		$i start
	done
fi
