#!/bin/sh

PREREQ=""
prereqs()
{
	echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

KVER="`uname -r`"
VMCORE="$rootmnt/boot/vmcoreinfo-$KVER"

grep -q kdump_needed /proc/cmdline || exit 0
test -e $VMCORE || exit 0
test -x /bin/makedumpfile || exit 0

. ./scripts/functions

log_begin_msg "Saving vmcore from kernel crash"

mount $rootmnt -o remount,rw

# Delete it if the copy fails, mainly to keep from filling up filesystems
# by accident.
makedumpfile -d 31 -i $VMCORE \
	/proc/vmcore $rootmnt/var/crash/vmcore > \
	$rootmnt/var/crash/vmcore.log 2>&1 || \
	rm -f $rootmnt/var/crash/vmcore

chmod 400 $rootmnt/var/crash/vmcore*

mount $rootmnt -o remount,ro
reboot

log_end_msg
