Sync glob(3) with FreeBSD:
[dragonfly.git] / etc / rc.d / savecore
blobbc62b77e08f0fbc0667b9cccda98046f628e1bf2
1 #!/bin/sh
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 $
5 # $DragonFly: src/etc/rc.d/savecore,v 1.6 2005/11/19 21:47:32 swildner Exp $
8 # PROVIDE: savecore
9 # REQUIRE: syslogd
10 # BEFORE: SERVERS
12 . /etc/rc.subr
14 name="savecore"
15 start_cmd="savecore_start"
16 start_precmd="savecore_prestart"
17 stop_cmd=":"
19 case ${OSTYPE} in
20 NetBSD)
21 rcvar=$name
23 esac
25 savecore_prestart()
27 # ${DUMPDIR} should be a directory or a symbolic link
28 # to the crash directory if core dumps are to be saved.
30 DUMPDIR="${dumpdir:-/var/crash}"
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
39 esac
40 # If there is no crash directory set it now
41 case ${dumpdir} in
42 '')
43 dumpdir='/var/crash'
45 [Nn][Oo])
46 dumpdir='NO'
48 esac
49 if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then
50 warn "Wrong dump device or directory. Savecore not run."
51 dumpdev=
52 return 0
54 return 0
57 savecore_start()
59 if [ X$dumpdev != X ]; then
60 echo "Checking for core dump..."
61 savecore ${savecore_flags} ${DUMPDIR}
62 return ${RC_CONFIGURED}
66 load_rc_config $name
67 run_rc_command "$1"