summaryrefslogtreecommitdiffstats
path: root/etc/rc.dumpon
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2011-01-25 16:53:43 -0500
committerjim-p <jimp@pfsense.org>2011-01-25 17:02:05 -0500
commitc3a56ba93a02b3a46b228dca83ff62e6abe591ff (patch)
treec5ebc9b133430456ab4e69900fb1a8bbc234a352 /etc/rc.dumpon
parent3b39d0ac8caeb83365865e7de767ec2b4f7b3c5a (diff)
downloadpfsense-c3a56ba93a02b3a46b228dca83ff62e6abe591ff.zip
pfsense-c3a56ba93a02b3a46b228dca83ff62e6abe591ff.tar.gz
Add support for dumpon/savecore to run on full installs.
Diffstat (limited to 'etc/rc.dumpon')
-rw-r--r--etc/rc.dumpon48
1 files changed, 48 insertions, 0 deletions
diff --git a/etc/rc.dumpon b/etc/rc.dumpon
new file mode 100644
index 0000000..e61fbbc
--- /dev/null
+++ b/etc/rc.dumpon
@@ -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
OpenPOWER on IntegriCloud