rc.shutdown revision 63311
1145519Sdarrenr#!/bin/sh 2145510Sdarrenr# $FreeBSD: head/etc/rc.shutdown 63311 2000-07-17 13:39:48Z sheldonh $ 322514Sdarrenr 453024Sguido# Site-specific closing actions for daemons run by init on shutdown, 522514Sdarrenr# or before going single-user from multi-user. 6145510Sdarrenr# Output and errors are directed to console by init, and the 722514Sdarrenr# console is the controlling terminal. 822514Sdarrenr 9145510Sdarrenrstty status '^T' 10145510Sdarrenr 11255332Scy# Set shell to ignore SIGINT (2), but not children; 1292686Sdarrenr# shell catches SIGQUIT (3) and returns to single user after fsck. 13145510Sdarrenrtrap : 2 1422514Sdarrenrtrap : 3 # shouldn't be needed 1522514Sdarrenr 1622514SdarrenrHOME=/ 1722514SdarrenrPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 1822514Sdarrenrexport HOME PATH 1922514Sdarrenr 2022514Sdarrenr# If there is a global system configuration file, suck it in. 2122514Sdarrenr# 22145510Sdarrenrif [ -r /etc/defaults/rc.conf ]; then 23145510Sdarrenr . /etc/defaults/rc.conf 24145510Sdarrenr source_rc_confs 25145510Sdarrenrelif [ -r /etc/rc.conf ]; then 26145510Sdarrenr . /etc/rc.conf 2724583Sdarrenrfi 2822514Sdarrenr 2922514Sdarrenr# Write some entropy so the rebooting /dev/random can reseed 3022514Sdarrenr# 3122514Sdarrenrcase ${entropy_file} in 3222514Sdarrenr[Nn][Oo] | '') 33255332Scy ;; 3422514Sdarrenr*) 3522514Sdarrenr echo "Writing entropy file" 3622514Sdarrenr rm -f ${entropy_file} 3722514Sdarrenr touch ${entropy_file} && \ 3822514Sdarrenr chmod 600 ${entropy_file} && \ 3922514Sdarrenr dd if=/dev/random of=${entropy_file} bs=4096 count=1 4022514Sdarrenr ;; 4122514Sdarrenresac 4222514Sdarrenr 4322514Sdarrenr# Check if /var/db/mounttab is clean. 4422514Sdarrenrcase $1 in 4522514Sdarrenrreboot) 4622514Sdarrenr if [ -f /var/db/mounttab ]; then 4722514Sdarrenr rpc.umntall 48369245Sgit2svn fi 49369245Sgit2svn ;; 5024583Sdarrenresac 5124583Sdarrenr 5224583Sdarrenrecho -n "Shutting down daemon processes: " 53255332Scy 5422514Sdarrenr# for each valid dir in $local_startup, search for init scripts matching *.sh 5522514Sdarrenrcase ${local_startup} in 5622514Sdarrenr[Nn][Oo] | '') 5722514Sdarrenr ;; 5822514Sdarrenr*) 5922514Sdarrenr for dir in ${local_startup}; do 6022514Sdarrenr if [ -d "${dir}" ]; then 6122514Sdarrenr for script in ${dir}/*.sh; do 6222514Sdarrenr if [ -x "${script}" ]; then 6322514Sdarrenr (set -T 6422514Sdarrenr trap 'exit 1' 2 6522514Sdarrenr ${script} stop) 6622514Sdarrenr fi 6722514Sdarrenr done 68255332Scy fi 69255332Scy done 7022514Sdarrenr echo . 7122514Sdarrenr ;; 7222514Sdarrenresac 7322514Sdarrenr 7431183Speter# Insert other shutdown procedures here 7531183Speter 7622514Sdarrenrecho '.' 7731183Speterexit 0 7822514Sdarrenr