~louis/crashdc/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# /bin/sh
# *****************************************************************
# *                                                               *
# *   Copyright 2009 Hewlett-Packard Development Company, L.P.    *
# *                                                               *
# *   crashdc may be copied only under the terms of the GNU       *
# *   General Public License, which may be found in the source    *
# *   kit.                                                        *
# *                                                               *
# *****************************************************************

#
# In order for this script to run correctly on SLES11,
# the crashkernel= boot param must be modified in order
# to increase the reserved memory that kexec will use.
# crashdc has been tested with the following :$
# crashkernel=256M-:128M@16M
#

#KDUMPSUCCESS=$1
#
# Changed for test
#
KDUMPSUCCESS=0
CRASHDCSUCCESS=0

. /etc/sysconfig/crashdc
. /etc/sysconfig/kdump
. /etc/rc.status

KDUMPSUCCESS=$?

if [ $KDUMPSUCCESS == 0 ];then
	crashexe=${MOUNTPREFIX}${CRASHEXE}
	coredir=`ls -rt ${MOUNTPREFIX}${VMCOREDIR}`
	set +a $coredir
	numdir=$#
	((numdir-=1))
	shift $numdir
	coredir=${MOUNTPREFIX}${VMCOREDIR}/$1
	namelist=$coredir/vmlinux-$(uname -r)
	namelist=${namelist%-kdump}
	if ! [ -r $namelist ];then
		#
		# namelist might have been uncompressed
		#
		if [ -f ${namelist}.gz ];then
			gzip -d -c ${namelist}.gz > $namelist
		else
			$LOGGER "Unable to locate $namelist. Verify that the \
			kernel-debuginfo packages are correctly installed \
			or uncompressed."
			false
			rc_status -v
			exit 1
		fi
	fi
	debuginfo=${MOUNTPREFIX}/usr/lib/debug/boot/vmlinux-$(uname -r).debug

	if ! [ -r $debuginfo ];then
		$LOGGER "Unable to locate $debuginfo. Verify that the \
		kernel-debuginfo packages are correctly installed \
		or uncompressed."
		false
		rc_status -v
		exit 1
	fi

	${CRASHDC} ${CRASHDCDEBUG} -x $crashexe $namelist $coredir/vmcore $coredir $debuginfo
	CRASHDCSUCCESS=$?
	if [ $CRASHDCSUCCESS == 0 ];then
		$LOGGER "generated a crash-data file to $coredir"
		rc_status -v
		exit 0
	else
		$LOGGER "Unable to generate a crash-data file"
		false
		rc_status -v
		exit 1
	fi
fi