savecore - Allow automatic text summary generation
[dragonfly.git] / etc / rc.d / savecore
CommitLineData
9c600e7d
MD
1#!/bin/sh
2#
3# $NetBSD: savecore,v 1.5 2002/03/22 04:34:00 thorpej Exp $
4# $FreeBSD: src/etc/rc.d/savecore,v 1.3 2002/09/06 16:18:05 gordon Exp $
696a5717 5# $DragonFly: src/etc/rc.d/savecore,v 1.6 2005/11/19 21:47:32 swildner Exp $
9c600e7d
MD
6#
7
8# PROVIDE: savecore
9# REQUIRE: syslogd
10# BEFORE: SERVERS
9c600e7d
MD
11
12. /etc/rc.subr
13
14name="savecore"
15start_cmd="savecore_start"
16start_precmd="savecore_prestart"
17stop_cmd=":"
18
19case ${OSTYPE} in
20NetBSD)
21 rcvar=$name
22 ;;
23esac
24
25savecore_prestart()
26{
27 # ${DUMPDIR} should be a directory or a symbolic link
28 # to the crash directory if core dumps are to be saved.
29 #
30 DUMPDIR="${dumpdir:-/var/crash}"
31
283b4f06
RG
32 # Quit if we have no dumb device
33 case ${dumpdev} in
34 [Nn][Oo] | '')
35 debug 'No dump device. Quitting.'
36 dumpdev=
37 return 0
38 ;;
39 esac
40 # If there is no crash directory set it now
41 case ${dumpdir} in
42 '')
43 dumpdir='/var/crash'
9c600e7d 44 ;;
283b4f06
RG
45 [Nn][Oo])
46 dumpdir='NO'
9c600e7d
MD
47 ;;
48 esac
283b4f06
RG
49 if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then
50 warn "Wrong dump device or directory. Savecore not run."
51 dumpdev=
52 return 0
53 fi
9c600e7d
MD
54 return 0
55}
56
57savecore_start()
58{
0c823069 59 if [ X$dumpdev != X ]; then
9c600e7d 60 echo "Checking for core dump..."
f8e9b4ce 61 savecore ${savecore_flags} ${DUMPDIR} ${dumpdev}
7fb3111b
AH
62 if checkyesno crashinfo_enable; then
63 ${crashinfo_program} -d ${DUMPDIR}
64 fi
015080b6 65 return ${RC_CONFIGURED}
0c823069 66 fi
9c600e7d
MD
67}
68
69load_rc_config $name
70run_rc_command "$1"