freebsd-dev/etc/rc.d/dumpon
Thomas Quinot e30c35ed0c When dumpdev is set to 'auto', and a suitable swap device is found,
create a symbolic link /dev/dumpdev designating that device so
savecore can find and save a previous kernel dump.
2004-10-18 23:40:13 +00:00

58 lines
923 B
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: dumpon
# REQUIRE: initrandom
# BEFORE: disks savecore
# KEYWORD: nojail
. /etc/rc.subr
name="dumpon"
start_cmd="dumpon_start"
stop_cmd="dumpon_stop"
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] | '')
;;
[Aa][Uu][Tt][Oo])
while read dev mp type more ; do
[ "${type}" = "swap" ] || continue
[ -c "${dev}" ] || continue
if /sbin/dumpon -v "${dev}" 2>/dev/null; then
# Make a symlink in devfs for savecore
ln -s ${dev} /dev/dumpdev
return 0
fi
done </etc/fstab
echo "No suitable dump device was found." 1>&2
return 1
;;
*)
/sbin/dumpon -v ${dumpdev}
;;
esac
}
dumpon_stop()
{
case ${dumpdev} in
[Nn][Oo] | '')
;;
*)
rm -f /dev/dumpdev
/sbin/dumpon -v off
;;
esac
}
load_rc_config $name
run_rc_command "$1"