rc.shutdown revision 63311
127837Sdavidn#!/bin/sh
250472Speter# $FreeBSD: head/etc/rc.shutdown 63311 2000-07-17 13:39:48Z sheldonh $
327837Sdavidn
451231Ssheldonh# Site-specific closing actions for daemons run by init on shutdown,
527837Sdavidn# or before going single-user from multi-user.
627837Sdavidn# Output and errors are directed to console by init, and the
727837Sdavidn# console is the controlling terminal.
827837Sdavidn
927837Sdavidnstty status '^T'
1027837Sdavidn
1127837Sdavidn# Set shell to ignore SIGINT (2), but not children;
1227837Sdavidn# shell catches SIGQUIT (3) and returns to single user after fsck.
1327837Sdavidntrap : 2
1427837Sdavidntrap : 3	# shouldn't be needed
1527837Sdavidn
1651231SsheldonhHOME=/
1727837SdavidnPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
1851231Ssheldonhexport HOME PATH
1927837Sdavidn
2062640Stg# If there is a global system configuration file, suck it in.
2162640Stg#
2262640Stgif [ -r /etc/defaults/rc.conf ]; then
2362640Stg	. /etc/defaults/rc.conf
2462640Stg	source_rc_confs
2562640Stgelif [ -r /etc/rc.conf ]; then
2662640Stg	. /etc/rc.conf
2762640Stgfi
2862640Stg
2963307Smarkm# Write some entropy so the rebooting /dev/random can reseed
3063307Smarkm#
3163307Smarkmcase ${entropy_file} in
3263307Smarkm[Nn][Oo] | '')
3363307Smarkm	;;
3463307Smarkm*)
3563311Ssheldonh	echo "Writing entropy file"
3663311Ssheldonh	rm -f ${entropy_file}
3763311Ssheldonh	touch ${entropy_file} && \
3863311Ssheldonh		chmod 600 ${entropy_file} && \
3963311Ssheldonh		dd if=/dev/random of=${entropy_file} bs=4096 count=1
4063307Smarkm	;;
4163307Smarkmesac
4263307Smarkm
4353550Sdillon# Check if /var/db/mounttab is clean.
4453550Sdilloncase $1 in
4553550Sdillonreboot)
4653550Sdillon	if [ -f /var/db/mounttab ]; then
4753550Sdillon		rpc.umntall
4853550Sdillon	fi
4953550Sdillon	;;
5053550Sdillonesac
5153550Sdillon
5251231Ssheldonhecho -n "Shutting down daemon processes: "
5327837Sdavidn
5462640Stg# for each valid dir in $local_startup, search for init scripts matching *.sh
5562640Stgcase ${local_startup} in
5662640Stg[Nn][Oo] | '')
5762640Stg	;;
5862640Stg*)
5962640Stg	for dir in ${local_startup}; do
6062640Stg		if [ -d "${dir}" ]; then
6162640Stg			for script in ${dir}/*.sh; do
6262640Stg				if [ -x "${script}" ]; then
6362640Stg					(set -T
6462640Stg					 trap 'exit 1' 2
6562640Stg					 ${script} stop)
6662640Stg				fi
6762640Stg			done
6862640Stg		fi
6962640Stg	done
7062640Stg	echo .
7162640Stg	;;
7262640Stgesac
7327837Sdavidn
7462640Stg# Insert other shutdown procedures here
7527837Sdavidn
7627837Sdavidnecho '.'
7727837Sdavidnexit 0
78