- Add a kdump sysconfig file and init script
- Spec file additions for pre/post install/uninstall
This commit is contained in:
parent
fdf6316037
commit
0112f3628c
110
kdump.init
Normal file
110
kdump.init
Normal file
@ -0,0 +1,110 @@
|
||||
#! /bin/sh
|
||||
|
||||
#
|
||||
# kdump
|
||||
#
|
||||
# Description: The kdump init script provides the support necessary for
|
||||
# loading a kdump kernel into memory at system bootup time,
|
||||
# and for copying away a vmcore at system panic time.
|
||||
#
|
||||
# Copyright 2005 Red Hat, Inc.
|
||||
#
|
||||
# chkconfig: 2345 20 80
|
||||
#
|
||||
# Author: Jeff Moyer <jmoyer@redhat.com>
|
||||
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
KEXEC=/usr/sbin/kexec
|
||||
|
||||
# Will be different for ia64, for example. For now, that architecture isn't
|
||||
# supported. Code needs to be added here when we do.
|
||||
BOOTDIR="/boot"
|
||||
|
||||
KDUMP_KERNELVER=""
|
||||
KDUMP_COMMANDLINE=""
|
||||
# KEXEC_HEADERS will not be in the sysconfig file by default
|
||||
KEXEC_HEADERS="--elf32-core-headers"
|
||||
KEXEC_ARGS=""
|
||||
|
||||
standard_kexec_args="-p --args-linux"
|
||||
|
||||
if [ -f /etc/sysconfig/kdump ]; then
|
||||
. /etc/sysconfig/kdump
|
||||
fi
|
||||
|
||||
function save_core()
|
||||
{
|
||||
coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`"
|
||||
|
||||
mkdir -p $coredir
|
||||
cp /proc/vmcore $coredir/vmcore
|
||||
}
|
||||
|
||||
# Load the kdump kerel specified in /etc/sysconfig/kdump
|
||||
# If none is specified, try to load a kdump kernel with the same version
|
||||
# as the currently running kernel.
|
||||
function load_kdump()
|
||||
{
|
||||
if [ -z "$KDUMP_KERNELVER" ]; then
|
||||
local running_kernel=`uname -r`
|
||||
|
||||
kdump_kver=`echo $running_kernel | sed 's/smp//g'`
|
||||
kdump_kver="${kdump_kver}kdump"
|
||||
else
|
||||
kdump_kver=$KDUMP_KERNELVER
|
||||
fi
|
||||
|
||||
kdump_kernel="${BOOTDIR}/vmlinux-${kdump_kver}"
|
||||
kdump_initrd="${BOOTDIR}/initrd-${kdump_kver}.img"
|
||||
|
||||
if [ ! -f $kdump_kernel ]; then
|
||||
echo "No kdump kernel image found."
|
||||
echo "Tried to locate ${kdump_kernel}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f $kdump_initrd ]; then
|
||||
echo "No kdump initial ramdisk found."
|
||||
echo "Tried to locate ${kdump_initrd}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$KDUMP_COMMANDLINE" ]; then
|
||||
KDUMP_COMMANDLINE=`cat /proc/cmdline`
|
||||
KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[0-9]\+M@[0-9]\+M//g'`
|
||||
fi
|
||||
|
||||
$KEXEC $KEXEC_ARGS $standard_kexec_args $KEXEC_HEADERS \
|
||||
"--command-line=\"$KDUMP_COMMANDLINE\"" \
|
||||
--initrd=$kdump_initrd $kdump_kernel
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if [ -f /proc/vmcore ]; then
|
||||
save_core
|
||||
reboot
|
||||
else
|
||||
load_kdump
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
$KEXEC -u
|
||||
;;
|
||||
status)
|
||||
echo "not implemented"
|
||||
;;
|
||||
restart)
|
||||
echo "not implemented"
|
||||
;;
|
||||
condrestart)
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
16
kdump.sysconfig
Normal file
16
kdump.sysconfig
Normal file
@ -0,0 +1,16 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
KEXEC_ARGS=""
|
@ -1,11 +1,13 @@
|
||||
Name: kexec-tools
|
||||
Version: 1.101
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: GPL
|
||||
Group: Applications/System
|
||||
Summary: The kexec/kdump userspace component.
|
||||
ExclusiveArch: %{ix86}
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
Source1: kdump.init
|
||||
Source2: kdump.sysconfig
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
|
||||
|
||||
#
|
||||
@ -37,6 +39,9 @@ component of the kernel's kexec feature.
|
||||
rm -f ../kexec-tools-1.101.spec
|
||||
%patch1 -p1
|
||||
|
||||
cp $RPM_SOURCE_DIR/kdump.init .
|
||||
cp $RPM_SOURCE_DIR/kdump.sysconfig .
|
||||
|
||||
%build
|
||||
%configure
|
||||
rm -f kexec-tools.spec.in
|
||||
@ -45,19 +50,44 @@ make
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
mkdir -p -m755 $RPM_BUILD_ROOT/etc/rc.d/init.d
|
||||
mkdir -p -m755 $RPM_BUILD_ROOT/etc/sysconfig
|
||||
install -m 644 kdump.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/kdump
|
||||
install -m 755 kdump.init $RPM_BUILD_ROOT/etc/rc.d/init.d/kdump
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
chkconfig --add kdump
|
||||
|
||||
%postun
|
||||
if [ "$1" -ge 1 ]; then
|
||||
/sbin/service kdump condrestart > /dev/null 2>&1 || :
|
||||
fi
|
||||
|
||||
%preun
|
||||
if [ "$1" = 0 ]; then
|
||||
/sbin/service kdump stop > /dev/null 2>&1 || :
|
||||
/sbin/chkconfig --del kdump
|
||||
fi
|
||||
exit 0
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%{_sbindir}/kexec
|
||||
%{_sbindir}/kdump
|
||||
%{_libdir}/kexec-tools/kexec_test
|
||||
%config(noreplace,missingok) /etc/sysconfig/kdump
|
||||
%config /etc/rc.d/init.d/kdump
|
||||
%doc News
|
||||
%doc COPYING
|
||||
%doc TODO
|
||||
|
||||
%changelog
|
||||
* Thu Aug 25 2005 Ananth Mavinakayanahalli <amavin@redhat.com>
|
||||
* Fri Sep 23 2005 Jeff Moyer <jmoyer@redhat.com> - 1.101-3
|
||||
- Add a kdump sysconfig file and init script
|
||||
- Spec file additions for pre/post install/uninstall
|
||||
|
||||
* Thu Aug 25 2005 Jeff Moyer <jmoyer@redhat.com>
|
||||
- Initial prototype for RH/FC5
|
||||
|
Loading…
Reference in New Issue
Block a user