Introduce kdump-lib.sh for kdump shared functions

Currently in the whole kdump framework, we have some common functions
used across not only mkdumprd context and dracut context, but also 1st
kernel and 2nd kernel. We defined these functions at each script, which
is obviously not decent.

So let's introduce kdump-lib.sh for the shared functions and put it
to /lib/kdump/kdump-lib.sh.

It starts small, as you can see, only 3 functions are extracted. But in
the future more and more common functions can be added.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
WANG Chao 2013-09-24 21:33:27 +08:00 committed by Baoquan He
parent 6a0fb27687
commit a8921f04ae
5 changed files with 27 additions and 35 deletions

View File

@ -2,6 +2,7 @@
exec &> /dev/console
. /lib/dracut-lib.sh
. /lib/kdump-lib.sh
if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then
rm -f -- $initdir/lib/dracut/no-emergency-shell
@ -198,21 +199,6 @@ save_vmcore_dmesg_ssh() {
}
is_ssh_dump_target()
{
grep -q "^ssh[[:blank:]].*@" $conf_file
}
is_nfs_dump_target()
{
grep -q "^nfs.*:" $conf_file
}
is_raw_dump_target()
{
grep -q "^raw" $conf_file
}
get_host_ip()
{
local _host

View File

@ -1,6 +1,7 @@
#!/bin/bash
. $dracutfunctions
. /lib/kdump/kdump-lib.sh
check() {
[[ $debug ]] && set -x
@ -23,11 +24,6 @@ depends() {
return 0
}
is_ssh_dump_target()
{
grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
}
kdump_to_udev_name() {
local dev="${1//\"/}"
@ -413,6 +409,7 @@ install() {
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst_hook pre-pivot 9999 "$moddir/kdump.sh"
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
# Check for all the devices and if any device is iscsi, bring up iscsi
# target. Ideally all this should be pushed into dracut iscsi module

19
kdump-lib.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
#
# Kdump common functions
#
is_ssh_dump_target()
{
grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
}
is_nfs_dump_target()
{
grep -q "^nfs" /etc/kdump.conf
}
is_raw_dump_target()
{
grep -q "^raw" /etc/kdump.conf
}

View File

@ -24,6 +24,7 @@ Source16: kdump.service
Source17: rhcrashkernel-param
Source18: kdump.sysconfig.s390x
Source19: eppic_030413.tar.gz
Source20: kdump-lib.sh
#######################################
# These are sources for mkdumpramfs
@ -156,6 +157,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir}
mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir}
mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl
SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
@ -168,6 +170,7 @@ install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/kdump/firstboot_kdump.py
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh
%ifnarch s390x
# For s390x the ELF header is created in the kdump kernel and therefore kexec
# udev rules are not required
@ -298,6 +301,7 @@ done
/usr/sbin/*
%{_bindir}/*
%{_datadir}/kdump
%{_prefix}/lib/kdump
%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump
%config(noreplace,missingok) %{_sysconfdir}/kdump.conf
%ifnarch s390x

View File

@ -6,6 +6,7 @@
# Written by Cong Wang <amwang@redhat.com>
#
. /lib/kdump/kdump-lib.sh
export IN_KDUMP=1
conf_file="/etc/kdump.conf"
@ -243,21 +244,6 @@ check_size() {
fi
}
is_nfs_dump_target()
{
grep -q "^nfs" $conf_file
}
is_ssh_dump_target()
{
grep -q "^ssh.*@" $conf_file
}
is_raw_dump_target()
{
grep -q "^raw" $conf_file
}
# $1: core_collector config value
verify_core_collector() {
if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then