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
|
|
|
|
# KEYWORD: FreeBSD NetBSD
|
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
|
|
|
case `${CMD_OSTYPE}` in
|
|
|
|
NetBSD)
|
|
|
|
rcvar=$name
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
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}"
|
|
|
|
|
|
|
|
case `${CMD_OSTYPE}` in
|
|
|
|
FreeBSD)
|
|
|
|
# Quit if we have no dump device
|
|
|
|
case ${dumpdev} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
debug 'No dump device. Quitting.'
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# If there is no crash directory set it now
|
|
|
|
case ${dumpdir} in
|
|
|
|
'')
|
|
|
|
dumpdir='/var/crash'
|
|
|
|
;;
|
|
|
|
[Nn][Oo])
|
|
|
|
dumpdir='NO'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then
|
|
|
|
warn "Wrong dump device or directory. Savecore not run."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
NetBSD)
|
|
|
|
if [ ! -d "${dumpdir}" ]; then
|
|
|
|
warn "No /var/crash directory; savecore not run."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
savecore_start()
|
|
|
|
{
|
2001-06-16 07:16:14 +00:00
|
|
|
echo "Checking for core dump..."
|
2002-06-13 22:14:37 +00:00
|
|
|
savecore ${savecore_flags} ${DUMPDIR}
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|