2002-06-13 22:14:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: dumpon
|
2010-05-19 19:03:19 +00:00
|
|
|
# BEFORE: disks
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="dumpon"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Dump kernel corefiles from swap to disk"
|
2002-06-13 22:14:37 +00:00
|
|
|
start_cmd="dumpon_start"
|
2004-02-02 19:05:06 +00:00
|
|
|
stop_cmd="dumpon_stop"
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2005-06-07 15:20:10 +00:00
|
|
|
dumpon_try()
|
|
|
|
{
|
2008-06-23 04:39:36 +00:00
|
|
|
if /sbin/dumpon "${1}" ; then
|
2005-06-07 15:20:10 +00:00
|
|
|
# Make a symlink in devfs for savecore
|
|
|
|
ln -fs "${1}" /dev/dumpdev
|
|
|
|
return 0
|
|
|
|
fi
|
2008-06-23 04:39:36 +00:00
|
|
|
warn "unable to specify $1 as a dump device"
|
2005-06-07 15:20:10 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2002-06-13 22:14:37 +00:00
|
|
|
dumpon_start()
|
|
|
|
{
|
|
|
|
# Enable dumpdev so that savecore can see it. Enable it
|
|
|
|
# early so a crash early in the boot process can be caught.
|
|
|
|
#
|
|
|
|
case ${dumpdev} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
2004-09-20 17:48:45 +00:00
|
|
|
[Aa][Uu][Tt][Oo])
|
2005-09-13 19:07:02 +00:00
|
|
|
dev=$(/bin/kenv -q dumpdev)
|
2005-06-07 15:20:10 +00:00
|
|
|
if [ -n "${dev}" ] ; then
|
|
|
|
dumpon_try "${dev}"
|
|
|
|
return $?
|
|
|
|
fi
|
2004-09-20 17:48:45 +00:00
|
|
|
while read dev mp type more ; do
|
|
|
|
[ "${type}" = "swap" ] || continue
|
|
|
|
[ -c "${dev}" ] || continue
|
2005-06-07 15:20:10 +00:00
|
|
|
dumpon_try "${dev}" 2>/dev/null && return 0
|
2004-09-20 17:48:45 +00:00
|
|
|
done </etc/fstab
|
|
|
|
echo "No suitable dump device was found." 1>&2
|
|
|
|
return 1
|
|
|
|
;;
|
2002-06-13 22:14:37 +00:00
|
|
|
*)
|
2005-06-07 15:20:10 +00:00
|
|
|
dumpon_try "${dumpdev}"
|
2002-06-13 22:14:37 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2004-02-02 19:05:06 +00:00
|
|
|
dumpon_stop()
|
|
|
|
{
|
|
|
|
case ${dumpdev} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
2004-10-18 23:40:13 +00:00
|
|
|
rm -f /dev/dumpdev
|
2004-02-02 19:05:06 +00:00
|
|
|
/sbin/dumpon -v off
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2002-06-13 22:14:37 +00:00
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|