Commit bd2d9f1c authored by Franco Fichtner's avatar Franco Fichtner

rc: refactor and simplify crash dump handling

parent 27b316be
......@@ -73,10 +73,9 @@ fi
# set keyboard map if needed
/etc/rc.d/syscons onestart
# probe for a persistent core dump device
/usr/local/etc/rc.dumpon
# set up and recover a crash dump before activating swap
/usr/local/etc/rc.crashdump
swapon -a
/usr/local/etc/rc.savecore
# Remove symlinks that are no longer needed
if [ -L /etc/dhclient.conf ]; then rm /etc/dhclient.conf; fi
......
#!/bin/sh
echo -n "Configuring crash dump device: "
while read DEV MP TYPE MORE; do
[ "${TYPE}" = "swap" ] || continue
[ -c "${DEV}" ] || continue
if dumpon ${DEV}; then
echo ${DEV}
if [ -n "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then
ddb /usr/local/etc/ddb.conf
fi
if savecore -C ${DEV} > /dev/null; then
savecore /var/crash ${DEV}
fi
exit 0
fi
done < /etc/fstab
echo "/dev/null"
#!/bin/sh
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
# ddb
if [ ! -z "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then
/sbin/ddb /usr/local/etc/ddb.conf
fi
#!/bin/sh
# Based on:
# FreeBSD: src/etc/rc.d/savecore,v 1.16.2.2.4.1 2010/06/14 02:09:06 kensmith Exp
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 "${dumpdev}" >/dev/null; then
savecore ${dumpdir} ${dumpdev}
else
echo 'No core dumps found.'
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment