#!/bin/ash

# System Shutdown Script
#

. /etc/rc.d/init.d/functions

echo
echo "System is going down for reboot or halt now."
echo


echo "Starting stop scripts."

for i in /etc/rc.d/stop/*
do
	if [ -x $i ]; then
		$i stop
	fi
done

if [ -x /sbin/hwclock ] && [ -e /dev/rtc ]; then
	echo -n "Syncing hardware clock to system clock:"
	hwclock --systohc --utc
	check_status
fi

if [ -x /sbin/swapoff ]; then
	echo -n "Disabling swap space: "
	swapoff -a
	check_status
fi

echo -n "Syncing all filesystems: "
sync
check_status

echo -n "Unmounting all filesystems: "
umount -a -r

