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