]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/savecore
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / etc / rc.d / savecore
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: savecore
7 # REQUIRE: syslogd
8 # BEFORE:  SERVERS
9 # KEYWORD: nojail
10
11 . /etc/rc.subr
12
13 name="savecore"
14 start_cmd="savecore_start"
15 start_precmd="savecore_prestart"
16 stop_cmd=":"
17
18 savecore_prestart()
19 {
20         #       ${DUMPDIR} should be a directory or a symbolic link
21         #       to the crash directory if core dumps are to be saved.
22         #
23         DUMPDIR="${dumpdir:-/var/crash}"
24
25         # Quit if we have no dump device
26         case ${dumpdev} in
27         [Nn][Oo] | '')
28                 debug 'No dump device. Quitting.'
29                 return 1
30                 ;;
31         [Aa][Uu][Tt][Oo])
32                 dumpdev=`/bin/realpath /dev/dumpdev`
33                 ;;
34         esac
35
36         # If there is no crash directory set it now
37         case ${dumpdir} in
38         '')
39                 dumpdir='/var/crash'
40                 ;;
41         [Nn][Oo])
42                 dumpdir='NO'
43                 ;;
44         esac
45
46         if [ ! -c "${dumpdev}" ]; then
47                 warn "Dump device does not exist.  Savecore not run."
48                 return 1
49         fi
50
51         if [ ! -d "${dumpdir}" ]; then
52                 warn "Dump directory does not exist.  Savecore not run."
53                 return 1
54         fi
55         return 0
56 }
57
58 savecore_start()
59 {
60         echo "Checking for core dump on ${dumpdev}..."
61         savecore ${savecore_flags} ${DUMPDIR} ${dumpdev}
62 }
63
64 load_rc_config $name
65 run_rc_command "$1"