Add support for dumpon/savecore to run on full installs.

This commit is contained in:
jim-p 2011-01-25 16:53:43 -05:00
parent 3b39d0ac8c
commit c3a56ba93a
2 changed files with 49 additions and 0 deletions

1
etc/rc
View File

@ -110,6 +110,7 @@ elif [ "$PLATFORM" = "nanobsd" ] ; then
/bin/rm -rf /var/db/pkg
/bin/ln -s /root/var/db/pkg/ /var/db/pkg
else
/etc/rc.dumpon
SWAPDEVICE=`/bin/cat /etc/fstab | /usr/bin/grep swap | /usr/bin/cut -f1`
/sbin/swapon -a 2>/dev/null >/dev/null
fi

48
etc/rc.dumpon Normal file
View File

@ -0,0 +1,48 @@
#!/bin/sh
# Based on:
# FreeBSD: src/etc/rc.d/dumpon,v 1.12.2.1.4.1 2010/06/14 02:09:06 kensmith Exp
# FreeBSD: src/etc/rc.d/savecore,v 1.16.2.2.4.1 2010/06/14 02:09:06 kensmith Exp
dumpon_try()
{
if /sbin/dumpon "${1}" ; then
# Make a symlink in devfs for savecore
echo "Using ${1} for dump device."
ln -fs "${1}" /dev/dumpdev
return 0
fi
echo "Unable to specify $1 as a dump device."
return 1
}
# Enable dumpdev so that savecore can see it. Enable it
# early so a crash early in the boot process can be caught.
#
while read dev mp type more ; do
[ "${type}" = "swap" ] || continue
[ -c "${dev}" ] || continue
dumpon_try "${dev}" && works=true
done </etc/fstab
if [ "${works}" != "true" ]; then
echo "No suitable dump device was found." 1>&2
exit
fi
dumpdev=`/bin/realpath /dev/dumpdev`
dumpdir='/var/crash'
if [ ! -c "${dumpdev}" ]; then
echo "Dump device does not exist. Savecore not run."
exit
fi
if [ ! -d "${dumpdir}" ]; then
echo "Dump directory does not exist. Savecore not run."
exit
fi
if savecore -C "${dumpdir}" "${dumpdev}" >/dev/null; then
savecore ${dumpdir} ${dumpdev}
else
echo 'No core dumps found.'
fi