Home | History | Annotate | Line # | Download | only in etc
rc.shutdown revision 1.5
      1  1.3  lukem #!/bin/sh
      2  1.3  lukem #
      3  1.5  lukem # $NetBSD: rc.shutdown,v 1.5 2000/12/15 00:00:09 lukem Exp $
      4  1.3  lukem #
      5  1.5  lukem # rc.shutdown --
      6  1.3  lukem #	Run the scripts in /etc/rc.d with reverse rcorder.
      7  1.5  lukem 
      8  1.5  lukem #	System shutdown script run by shutdown(8) at system shutdown time.
      9  1.5  lukem #	Note that halt(8) and reboot(8) do NOT invoke this script.
     10  1.1    bad 
     11  1.1    bad export HOME=/
     12  1.3  lukem export PATH=/sbin:/bin:/usr/sbin:/usr/bin
     13  1.1    bad 
     14  1.3  lukem . /etc/rc.subr
     15  1.3  lukem . /etc/rc.conf
     16  1.1    bad 
     17  1.3  lukem if ! checkyesno do_rcshutdown; then
     18  1.1    bad 	echo "Skipping shutdown hooks."
     19  1.1    bad 	exit 0
     20  1.1    bad fi
     21  1.1    bad 
     22  1.3  lukem stty status '^T'
     23  1.1    bad 
     24  1.3  lukem #	Set shell to ignore SIGINT (2), but not children;
     25  1.3  lukem #	shell catches SIGQUIT (3) and returns to single user.
     26  1.3  lukem #
     27  1.3  lukem trap : 2
     28  1.3  lukem trap "echo 'Shutdown interrupted.'; exit 1" 3
     29  1.3  lukem 
     30  1.4  lukem files=`rcorder -k shutdown /etc/rc.d/*`
     31  1.3  lukem for i in $files; do			# reverse order of files
     32  1.3  lukem 	nfiles="$i $nfiles"
     33  1.3  lukem done
     34  1.3  lukem files=$nfiles
     35  1.3  lukem 
     36  1.3  lukem for i in $files; do
     37  1.3  lukem 	run_rc_script $i stop
     38  1.3  lukem done
     39  1.1    bad 
     40  1.3  lukem date
     41  1.1    bad exit 0
     42