rc.shutdown revision 63307
1#!/bin/sh 2# $FreeBSD: head/etc/rc.shutdown 63307 2000-07-17 12:28:58Z markm $ 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 if [ -f ${entropy_file} -a -r ${entropy_file} ] ; then 36 echo -n "Writing entropy file" 37 touch ${entropy_file} && \ 38 chmod 600 ${entropy_file} && \ 39 dd if=/dev/random of=${entropy_file} bs=4096 count=1 40 fi 41 ;; 42esac 43 44# Check if /var/db/mounttab is clean. 45case $1 in 46reboot) 47 if [ -f /var/db/mounttab ]; then 48 rpc.umntall 49 fi 50 ;; 51esac 52 53echo -n "Shutting down daemon processes: " 54 55# for each valid dir in $local_startup, search for init scripts matching *.sh 56case ${local_startup} in 57[Nn][Oo] | '') 58 ;; 59*) 60 for dir in ${local_startup}; do 61 if [ -d "${dir}" ]; then 62 for script in ${dir}/*.sh; do 63 if [ -x "${script}" ]; then 64 (set -T 65 trap 'exit 1' 2 66 ${script} stop) 67 fi 68 done 69 fi 70 done 71 echo . 72 ;; 73esac 74 75# Insert other shutdown procedures here 76 77echo '.' 78exit 0 79