1#!/bin/bash -ex 2# 3# Setup for kdump test driver. 4# 5# This file is copied from kdump test case of LTP. 6# 7# This file is released under the GPLv2. 8# 9 10conf=${1} 11arch=$(uname -m) 12kver=$(uname -r) 13 14. "${conf}" 15 16echo "Verify Kernel version >= 2.6.16." 17# Kernel might in the following format. 18# x.y.z-1.el 19# x.y.z.1.el 20kx=${kver%%.*} 21tmp=${kver#*.} 22ky=${tmp%%.*} 23tmp=${tmp#*.} 24tmp=${tmp%%.*} 25kz=${tmp%%-*} 26 27if [ "${kx}" -lt 2 ]; then 28 error=1 29 30elif [ "${kx}" -eq 2 ]; then 31 if [ "${ky}" -lt 6 ]; then 32 error=1 33 34 elif [ "${ky}" -eq 6 ]; then 35 if [ "${kz}" -lt 16 ]; then 36 error=1 37 fi 38 fi 39fi 40 41if [ "${error}" ]; then 42 echo "Fail: kernel version ${kver} is less than 2.6.16." 43fi 44 45 46echo "Verify user is root." 47if [ $(id -u) != 0 ]; then 48 echo "Fail: root is required." 49 error=1 50fi 51 52 53echo "Verify prerequisite." 54if [ ! -x "/sbin/kexec" ]; then 55 echo "Fail: kexec-tools not found." 56 error=1 57fi 58 59if [ ! -d "/lib/modules/${kver}/build" ]; then 60 echo "Fail: kernel-devel not found." 61 error=1 62fi 63 64if [ "${CRASH}" ] && [ "${CRASH}" -eq 1 ]; then 65 if [ ! -x "/usr/bin/crash" ]; then 66 echo "Fail: crash not found." 67 error=1 68 fi 69 70 if [ ! -f "${VMLINUX}" ]; then 71 echo "Fail: kernel-debuginfo not found." 72 error=1 73 fi 74fi 75 76# Final result. 77if [ "${error}" ]; then 78 echo "Please fixed the above failures before continuing." 79 exit 1 80fi 81 82echo "Modify Boot Loader." 83if [ "${arch}" = "ppc64" ]; then 84 args="crashkernel=256M@32M xmon=off" 85elif [ "${arch}" = "i686" ]; then 86 args="crashkernel=128M@16M nmi_watchdog=1" 87elif [ "${arch}" = "ia64" ]; then 88 args="crashkernel=512M@256M" 89else 90 args="crashkernel=128M@16M" 91fi 92 93if [ -x "/sbin/grubby" ]; then 94 /sbin/grubby --default-kernel | 95 xargs /sbin/grubby --args="${args}" --update-kernel 96 97else 98 echo "Warn: please make sure the following arguments are in Boot\ 99 Loader:" 100 echo "$args" 101 echo "Hit any key when ready." 102 read 103fi 104 105exit 0 106