2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: savecore
|
2010-05-19 19:03:19 +00:00
|
|
|
# REQUIRE: dumpon ddb syslogd
|
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
|
|
|
{
|
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])
|
2013-03-19 05:08:25 +00:00
|
|
|
if [ ! -L /dev/dumpdev ]; then
|
2013-03-19 04:42:04 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2004-10-24 13:04:09 +00:00
|
|
|
dumpdev=`/bin/realpath /dev/dumpdev`
|
2004-10-18 23:40:13 +00:00
|
|
|
;;
|
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
|
|
|
|
2004-10-24 13:04:09 +00:00
|
|
|
if [ ! -c "${dumpdev}" ]; then
|
|
|
|
warn "Dump device does not exist. Savecore not run."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "${dumpdir}" ]; then
|
|
|
|
warn "Dump directory does not exist. Savecore not run."
|
2004-01-17 10:59:43 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
savecore_start()
|
|
|
|
{
|
2008-07-06 07:51:29 +00:00
|
|
|
local dev
|
|
|
|
|
|
|
|
case "${dumpdev}" in
|
|
|
|
[Aa][Uu][Tt][Oo])
|
|
|
|
dev=
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
dev="${dumpdev}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-12-14 15:12:08 +00:00
|
|
|
if savecore -C "${dev}" >/dev/null; then
|
2008-07-06 08:31:29 +00:00
|
|
|
savecore ${savecore_flags} ${dumpdir} ${dumpdev}
|
2008-08-29 20:30:30 +00:00
|
|
|
if checkyesno crashinfo_enable; then
|
|
|
|
${crashinfo_program} -d ${dumpdir}
|
|
|
|
fi
|
2008-06-23 20:54:32 +00:00
|
|
|
else
|
2009-10-10 22:17:03 +00:00
|
|
|
check_startmsgs && echo 'No core dumps found.'
|
2008-06-23 20:54:32 +00:00
|
|
|
fi
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|