2013-12-21 14:51:11 -06:00
|
|
|
#!@SBINDIR@/openrc-run
|
2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-29 19:46:31 -04:00
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-23 12:04:11 +00:00
|
|
|
|
|
|
|
description="Saves a kernel dump."
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
depend()
|
|
|
|
{
|
2012-07-15 08:47:02 -04:00
|
|
|
need dumpon localmount
|
|
|
|
before encswap
|
2012-07-02 22:04:22 -05:00
|
|
|
keyword -jail -prefix
|
2007-11-23 12:04:11 +00:00
|
|
|
}
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
start()
|
|
|
|
{
|
2009-04-27 07:51:18 +00:00
|
|
|
: ${dump_dir:=/var/crash}
|
|
|
|
if ! [ -d "$dump_dir" ]; then
|
|
|
|
mkdir -p "$dump_dir"
|
|
|
|
chmod 700 "$dump_dir"
|
2007-11-23 12:04:11 +00:00
|
|
|
fi
|
|
|
|
|
2009-04-27 07:51:18 +00:00
|
|
|
if [ "$RC_UNAME" = FreeBSD ]; then
|
2007-11-23 12:04:11 +00:00
|
|
|
# Don't quote ${dump_device}, so that if it's unset,
|
|
|
|
# savecore will check on the partitions listed in fstab
|
|
|
|
# without errors in the output
|
2015-03-04 09:07:12 +00:00
|
|
|
savecore -C $dump_device >/dev/null
|
2007-11-23 12:04:11 +00:00
|
|
|
else
|
2009-04-27 07:51:18 +00:00
|
|
|
ls "$dump_dir"/bsd* > /dev/null 2>&1
|
2007-11-23 12:04:11 +00:00
|
|
|
fi
|
|
|
|
[ $? = 0 ] || return 0
|
|
|
|
|
2009-04-27 07:51:18 +00:00
|
|
|
local sopts="$dump_dir $dump_device"
|
|
|
|
yesno $dump_compress && sopts="-z $sopts"
|
|
|
|
ebegin "Saving kernel core dump in $dump_dir"
|
|
|
|
savecore $sopts >/dev/null
|
2007-11-23 12:04:11 +00:00
|
|
|
eend $?
|
|
|
|
}
|