rc.shutdown revision 63801
1#!/bin/sh 2# $FreeBSD: head/etc/rc.shutdown 63801 2000-07-24 15:14:47Z sheldonh $ 3 4# Site-specific closing actions for daemons run by init on shutdown, 5# or before going single-user from multi-user. 6# Output and errors are directed to console by init, and the 7# console is the controlling terminal. 8 9stty status '^T' 10 11# Set shell to ignore SIGINT (2), but not children; 12# shell catches SIGQUIT (3) and returns to single user after fsck. 13trap : 2 14trap : 3 # shouldn't be needed 15 16HOME=/ 17PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 18export HOME PATH 19 20# If there is a global system configuration file, suck it in. 21# 22if [ -r /etc/defaults/rc.conf ]; then 23 . /etc/defaults/rc.conf 24 source_rc_confs 25elif [ -r /etc/rc.conf ]; then 26 . /etc/rc.conf 27fi 28 29# Write some entropy so the rebooting /dev/random can reseed 30# 31case ${entropy_file} in 32[Nn][Oo] | '') 33 ;; 34*) 35 echo "Writing entropy file." 36 rm -f ${entropy_file} 37 oumask=`umask` 38 umask 077 39 touch ${entropy_file} && \ 40 dd if=/dev/random of=${entropy_file} \ 41 bs=4096 count=1 2> /dev/null 42 umask ${oumask} 43 ;; 44esac 45 46# Check if /var/db/mounttab is clean. 47case $1 in 48reboot) 49 if [ -f /var/db/mounttab ]; then 50 rpc.umntall 51 fi 52 ;; 53esac 54 55echo -n "Shutting down daemon processes: " 56 57# for each valid dir in $local_startup, search for init scripts matching *.sh 58case ${local_startup} in 59[Nn][Oo] | '') 60 ;; 61*) 62 for dir in ${local_startup}; do 63 if [ -d "${dir}" ]; then 64 for script in ${dir}/*.sh; do 65 if [ -x "${script}" ]; then 66 (set -T 67 trap 'exit 1' 2 68 ${script} stop) 69 fi 70 done 71 fi 72 done 73 echo . 74 ;; 75esac 76 77# Insert other shutdown procedures here 78 79echo '.' 80exit 0 81