2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $NetBSD: savecore,v 1.5 2002/03/22 04:34:00 thorpej Exp $
|
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: savecore
|
|
|
|
# REQUIRE: syslogd
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: SERVERS
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="savecore"
|
|
|
|
start_cmd="savecore_start"
|
2002-06-13 22:14:37 +00:00
|
|
|
start_precmd="savecore_prestart"
|
2001-06-16 07:16:14 +00:00
|
|
|
stop_cmd=":"
|
|
|
|
|
2002-06-13 22:14:37 +00:00
|
|
|
savecore_prestart()
|
2001-06-16 07:16:14 +00:00
|
|
|
{
|
2002-06-13 22:14:37 +00:00
|
|
|
# ${DUMPDIR} should be a directory or a symbolic link
|
2001-06-16 07:16:14 +00:00
|
|
|
# to the crash directory if core dumps are to be saved.
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
DUMPDIR="${dumpdir:-/var/crash}"
|
|
|
|
|
2004-01-17 10:59:43 +00:00
|
|
|
# Quit if we have no dump device
|
|
|
|
case ${dumpdev} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
debug 'No dump device. Quitting.'
|
|
|
|
return 1
|
|
|
|
;;
|
2004-10-18 23:40:13 +00:00
|
|
|
[Aa][Uu][Tt][Oo])
|
|
|
|
dumpdev=/dev/dumpdev
|
|
|
|
;;
|
2004-01-17 10:59:43 +00:00
|
|
|
esac
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2004-01-17 10:59:43 +00:00
|
|
|
# If there is no crash directory set it now
|
|
|
|
case ${dumpdir} in
|
|
|
|
'')
|
|
|
|
dumpdir='/var/crash'
|
2002-06-13 22:14:37 +00:00
|
|
|
;;
|
2004-01-17 10:59:43 +00:00
|
|
|
[Nn][Oo])
|
|
|
|
dumpdir='NO'
|
2002-06-13 22:14:37 +00:00
|
|
|
;;
|
|
|
|
esac
|
2004-01-17 10:59:43 +00:00
|
|
|
|
|
|
|
if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then
|
|
|
|
warn "Wrong dump device or directory. Savecore not run."
|
|
|
|
return 1
|
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
savecore_start()
|
|
|
|
{
|
2004-10-18 23:40:13 +00:00
|
|
|
echo "Checking for core dump on ${dumpdev}..."
|
|
|
|
savecore ${savecore_flags} ${DUMPDIR} ${dumpdev}
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|