]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.shutdown
dd is too verbose writting entropy, redirect its output to /dev/null
[FreeBSD/FreeBSD.git] / etc / rc.shutdown
1 #!/bin/sh
2 # $FreeBSD$
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
9 stty 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.
13 trap : 2
14 trap : 3        # shouldn't be needed
15
16 HOME=/
17 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
18 export HOME PATH
19
20 # If there is a global system configuration file, suck it in.
21 #
22 if [ -r /etc/defaults/rc.conf ]; then
23         . /etc/defaults/rc.conf
24         source_rc_confs
25 elif [ -r /etc/rc.conf ]; then
26         . /etc/rc.conf
27 fi
28
29 # Write some entropy so the rebooting /dev/random can reseed
30 #
31 case ${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} \
40                    bs=4096 count=1 2> /dev/null
41         ;;
42 esac
43
44 # Check if /var/db/mounttab is clean.
45 case $1 in
46 reboot)
47         if [ -f /var/db/mounttab ]; then
48                 rpc.umntall
49         fi
50         ;;
51 esac
52
53 echo -n "Shutting down daemon processes: "
54
55 # for each valid dir in $local_startup, search for init scripts matching *.sh
56 case ${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         ;;
73 esac
74
75 # Insert other shutdown procedures here
76
77 echo '.'
78 exit 0