rc.shutdown revision 63307
127837Sdavidn#!/bin/sh 250472Speter# $FreeBSD: head/etc/rc.shutdown 63307 2000-07-17 12:28:58Z markm $ 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*) 3563307Smarkm if [ -f ${entropy_file} -a -r ${entropy_file} ] ; then 3663307Smarkm echo -n "Writing entropy file" 3763307Smarkm touch ${entropy_file} && \ 3863307Smarkm chmod 600 ${entropy_file} && \ 3963307Smarkm dd if=/dev/random of=${entropy_file} bs=4096 count=1 4063307Smarkm fi 4163307Smarkm ;; 4263307Smarkmesac 4363307Smarkm 4453550Sdillon# Check if /var/db/mounttab is clean. 4553550Sdilloncase $1 in 4653550Sdillonreboot) 4753550Sdillon if [ -f /var/db/mounttab ]; then 4853550Sdillon rpc.umntall 4953550Sdillon fi 5053550Sdillon ;; 5153550Sdillonesac 5253550Sdillon 5351231Ssheldonhecho -n "Shutting down daemon processes: " 5427837Sdavidn 5562640Stg# for each valid dir in $local_startup, search for init scripts matching *.sh 5662640Stgcase ${local_startup} in 5762640Stg[Nn][Oo] | '') 5862640Stg ;; 5962640Stg*) 6062640Stg for dir in ${local_startup}; do 6162640Stg if [ -d "${dir}" ]; then 6262640Stg for script in ${dir}/*.sh; do 6362640Stg if [ -x "${script}" ]; then 6462640Stg (set -T 6562640Stg trap 'exit 1' 2 6662640Stg ${script} stop) 6762640Stg fi 6862640Stg done 6962640Stg fi 7062640Stg done 7162640Stg echo . 7262640Stg ;; 7362640Stgesac 7427837Sdavidn 7562640Stg# Insert other shutdown procedures here 7627837Sdavidn 7727837Sdavidnecho '.' 7827837Sdavidnexit 0 79