#	$NetBSD: rc.shutdown,v 1.1 1998/10/29 20:24:57 bad Exp $

# System shutdown script run by shutdown before halting/rebooting
# or going single-user.

stty status '^T'

export HOME=/
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
else
	echo "Can't read /etc/rc.subr; aborting."
	exit 1;
fi

if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

if checkyesno do_rcshutdown; then
	: # Everything's hunkdory
else
	echo "Skipping shutdown hooks."
	exit 0
fi

if [ -f /etc/rc.shutdown.local ]; then
	. /etc/rc.shutdown.local
fi

# Kill xdm and wait for it to terminate.
if checkyesno xdm; then
	XDM_PID=`sed 1q /var/run/xdm-pid`
	if [ -n "$XDM_PID" ]; then
		echo -n ' xdm'
		kill $XDM_PID
		while kill -0 $XDM_PID; do
			sleep 1
		done
	fi
fi

exit 0
