freebsd-nq/etc/rc.d/dumpon

58 lines
923 B
Plaintext
Raw Normal View History

#!/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"