mkdumprd: use shutdown module of dracut to handle reboot/shutdown/halt.
This commit is contained in:
parent
74a0255dff
commit
108f6ac2cc
@ -5,6 +5,5 @@ inst "/bin/sync" "/bin/sync"
|
|||||||
inst "/usr/bin/reboot" "/bin/reboot"
|
inst "/usr/bin/reboot" "/bin/reboot"
|
||||||
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
||||||
inst "/etc/kdump.conf" "/etc/kdump.conf"
|
inst "/etc/kdump.conf" "/etc/kdump.conf"
|
||||||
inst "$moddir/kdump-lib.sh" "/lib/kdump-lib.sh"
|
inst_hook pre-pivot 01 "$moddir/kdump.sh"
|
||||||
inst_hook pre-pivot 01 "$moddir/kdump_localfs.sh"
|
|
||||||
|
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/dracut-lib.sh
|
|
||||||
|
|
||||||
KDUMP_PATH="/var/crash"
|
|
||||||
CORE_COLLECTOR="makedumpfile -d 31 -c"
|
|
||||||
DEFAULT_ACTION="reboot -f"
|
|
||||||
|
|
||||||
read_kdump_conf()
|
|
||||||
{
|
|
||||||
local conf_file="/etc/kdump.conf"
|
|
||||||
if [ -f "$conf_file" ]; then
|
|
||||||
while read config_opt config_val;
|
|
||||||
do
|
|
||||||
case "$config_opt" in
|
|
||||||
path)
|
|
||||||
KDUMP_PATH="$config_val"
|
|
||||||
;;
|
|
||||||
core_collector)
|
|
||||||
CORE_COLLECTOR="$config_val"
|
|
||||||
;;
|
|
||||||
default)
|
|
||||||
case $config_val in
|
|
||||||
shell)
|
|
||||||
DEFAULT_ACTION="sh -i -l"
|
|
||||||
;;
|
|
||||||
reboot)
|
|
||||||
DEFAULT_ACTION="reboot -f"
|
|
||||||
;;
|
|
||||||
halt)
|
|
||||||
DEFAULT_ACTION="halt -f"
|
|
||||||
;;
|
|
||||||
poweroff)
|
|
||||||
DEFAULT_ACTION="poweroff -f"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done < $conf_file
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
do_default_action()
|
|
||||||
{
|
|
||||||
wait_for_loginit
|
|
||||||
$DEFAULT_ACTION
|
|
||||||
}
|
|
||||||
|
|
105
kdump_dracut_modules/99kdumpbase/kdump.sh
Executable file
105
kdump_dracut_modules/99kdumpbase/kdump.sh
Executable file
@ -0,0 +1,105 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/dracut-lib.sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
KDUMP_PATH="/var/crash"
|
||||||
|
CORE_COLLECTOR="makedumpfile -d 31 -c"
|
||||||
|
DEFAULT_ACTION="reboot -f"
|
||||||
|
DATEDIR=`date +%d.%m.%y-%T`
|
||||||
|
DUMP_INSTRUCTION=""
|
||||||
|
|
||||||
|
do_default_action()
|
||||||
|
{
|
||||||
|
wait_for_loginit
|
||||||
|
$DEFAULT_ACTION
|
||||||
|
}
|
||||||
|
|
||||||
|
add_dump_instruction()
|
||||||
|
{
|
||||||
|
if [ -z "$DUMP_INSTRUCTION" ]
|
||||||
|
then
|
||||||
|
DUMP_INSTRUCTION="$1"
|
||||||
|
else
|
||||||
|
DUMP_INSTRUCTION="$DUMP_INSTRUCTION && $1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
dump_rootfs()
|
||||||
|
{
|
||||||
|
mount -o remount,rw $NEWROOT/ || return 1
|
||||||
|
mkdir -p $NEWROOT/$KDUMP_PATH/$DATEDIR
|
||||||
|
$CORE_COLLECTOR /proc/vmcore $NEWROOT/$KDUMP_PATH/$DATEDIR/vmcore || return 1
|
||||||
|
sync
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
dump_nfs()
|
||||||
|
{
|
||||||
|
mount -o nolock -o tcp -t nfs $1 $NEWROOT/mnt/
|
||||||
|
mkdir -p $NEWROOT/mnt/$KDUMP_PATH/$DATEDIR || return 1
|
||||||
|
$CORE_COLLECTOR /proc/vmcore $NEWROOT/mnt/$KDUMP_PATH/$DATEDIR/vmcore || return 1
|
||||||
|
umount $NEWROOT/mnt/ || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
dump_ssh()
|
||||||
|
{
|
||||||
|
ssh -q -o BatchMode=yes -o StrictHostKeyChecking=yes $1 mkdir -p $KDUMP_PATH/$DATEDIR || return 1
|
||||||
|
scp -q -o BatchMode=yes -o StrictHostKeyChecking=yes /proc/vmcore "$1:$KDUMP_PATH/$DATEDIR" || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
read_kdump_conf()
|
||||||
|
{
|
||||||
|
local conf_file="/etc/kdump.conf"
|
||||||
|
if [ -f "$conf_file" ]; then
|
||||||
|
while read config_opt config_val;
|
||||||
|
do
|
||||||
|
case "$config_opt" in
|
||||||
|
path)
|
||||||
|
KDUMP_PATH="$config_val"
|
||||||
|
;;
|
||||||
|
core_collector)
|
||||||
|
CORE_COLLECTOR="$config_val"
|
||||||
|
;;
|
||||||
|
net)
|
||||||
|
if [ -n "$(echo $config_val | grep @)" ]
|
||||||
|
then
|
||||||
|
add_dump_instruction "dump_ssh $config_val || do_default_action"
|
||||||
|
else
|
||||||
|
add_dump_instruction "dump_nfs $config_val || do_default_action"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
default)
|
||||||
|
case $config_val in
|
||||||
|
shell)
|
||||||
|
DEFAULT_ACTION="sh -i -l"
|
||||||
|
;;
|
||||||
|
reboot)
|
||||||
|
DEFAULT_ACTION="reboot -f"
|
||||||
|
;;
|
||||||
|
halt)
|
||||||
|
DEFAULT_ACTION="halt -f"
|
||||||
|
;;
|
||||||
|
poweroff)
|
||||||
|
DEFAULT_ACTION="poweroff -f"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < $conf_file
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
read_kdump_conf
|
||||||
|
|
||||||
|
if [ -n "$DUMP_INSTRUCTION" ]
|
||||||
|
then
|
||||||
|
eval "$DUMP_INSTRUCTION"
|
||||||
|
else
|
||||||
|
dump_rootfs
|
||||||
|
do_default_action
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/kdump-lib.sh
|
|
||||||
read_kdump_conf
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# We have the root file system mounted under $NEWROOT, so copy
|
|
||||||
# the vmcore there and call it a day
|
|
||||||
#
|
|
||||||
DATEDIR=`date +%d.%m.%y-%T`
|
|
||||||
|
|
||||||
mount -o remount,rw $NEWROOT/
|
|
||||||
mkdir -p $NEWROOT/$KDUMP_PATH/$DATEDIR
|
|
||||||
$CORE_COLLECTOR /proc/vmcore $NEWROOT/$KDUMP_PATH/$DATEDIR/vmcore
|
|
||||||
sync
|
|
||||||
|
|
||||||
do_default_action
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
Name: kexec-tools
|
Name: kexec-tools
|
||||||
Version: 2.0.2
|
Version: 2.0.2
|
||||||
Release: 14%{?dist}
|
Release: 15%{?dist}
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
Summary: The kexec/kdump userspace component.
|
Summary: The kexec/kdump userspace component.
|
||||||
@ -169,7 +169,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf
|
|||||||
tar -C $RPM_BUILD_ROOT/etc/kdump-adv-conf -jxvf %{SOURCE100}
|
tar -C $RPM_BUILD_ROOT/etc/kdump-adv-conf -jxvf %{SOURCE100}
|
||||||
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/check
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/check
|
||||||
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/install
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/install
|
||||||
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/kdump_localfs.sh
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/kdump.sh
|
||||||
|
|
||||||
|
|
||||||
#and move the custom dracut modules to the dracut directory
|
#and move the custom dracut modules to the dracut directory
|
||||||
@ -281,6 +281,9 @@ done
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jul 28 2011 Cong Wang <xiyou.wangcong@gmail.com> - 2.0.2-15
|
||||||
|
- Use shutdown module of dracut to handle reboot/shutdown/halt.
|
||||||
|
|
||||||
* Wed Jul 27 2011 Cong Wang <xiyou.wangcong@gmail.com> - 2.0.2-14
|
* Wed Jul 27 2011 Cong Wang <xiyou.wangcong@gmail.com> - 2.0.2-14
|
||||||
- Wait for loginit.
|
- Wait for loginit.
|
||||||
|
|
||||||
|
14
mkdumprd
14
mkdumprd
@ -10,7 +10,7 @@ export IN_KDUMP=1
|
|||||||
|
|
||||||
conf_file="/etc/kdump.conf"
|
conf_file="/etc/kdump.conf"
|
||||||
extra_modules=""
|
extra_modules=""
|
||||||
dracut_args="-H -o i18n -o plymouth"
|
dracut_args="-H -o i18n -o plymouth --add shutdown -c /dev/null"
|
||||||
|
|
||||||
add_dracut_arg() {
|
add_dracut_arg() {
|
||||||
dracut_args="$dracut_args $*"
|
dracut_args="$dracut_args $*"
|
||||||
@ -38,12 +38,12 @@ done
|
|||||||
|
|
||||||
# $1 target device
|
# $1 target device
|
||||||
# $2 if this is a raw dump
|
# $2 if this is a raw dump
|
||||||
dump_local() {
|
check_local() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 remote target
|
# $1 remote target
|
||||||
dump_remote() {
|
check_remote() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,14 +55,14 @@ if [ -n "$conf_file" ]; then
|
|||||||
extra_modules="$extra_modules $config_val"
|
extra_modules="$extra_modules $config_val"
|
||||||
;;
|
;;
|
||||||
ext[234]|xfs|btrfs|minix)
|
ext[234]|xfs|btrfs|minix)
|
||||||
dump_local "$config_val" 0
|
check_local "$config_val" 0
|
||||||
;;
|
;;
|
||||||
raw)
|
raw)
|
||||||
dump_local "$config_val" 1
|
check_local "$config_val" 1
|
||||||
;;
|
;;
|
||||||
net)
|
net)
|
||||||
add_dracut_arg "--add network"
|
add_dracut_arg "--add network"
|
||||||
dump_remote "$config_val"
|
check_remote "$config_val"
|
||||||
;;
|
;;
|
||||||
core_collector)
|
core_collector)
|
||||||
add_dracut_arg "-I ${config_val% *}"
|
add_dracut_arg "-I ${config_val% *}"
|
||||||
@ -75,7 +75,6 @@ if [ -n "$conf_file" ]; then
|
|||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
dump_local ""
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < $conf_file
|
done < $conf_file
|
||||||
@ -87,4 +86,5 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dracut $dracut_args "$@"
|
dracut $dracut_args "$@"
|
||||||
|
exit $?
|
||||||
|
|
||||||
|
3
sources
3
sources
@ -9,3 +9,6 @@ d872bdde29eb036cd59e7b71c148fca6 dracut-files.tbz2
|
|||||||
7d1516ae8af7000cec149b9409f9b859 dracut-files.tbz2
|
7d1516ae8af7000cec149b9409f9b859 dracut-files.tbz2
|
||||||
ea7a345cbaa0d3d9a9dbd46631155550 dracut-files.tbz2
|
ea7a345cbaa0d3d9a9dbd46631155550 dracut-files.tbz2
|
||||||
d220ff5e4b07c34701d9a1fe991ef2e4 dracut-files.tbz2
|
d220ff5e4b07c34701d9a1fe991ef2e4 dracut-files.tbz2
|
||||||
|
1548d83e2713660c4cbd2c284fdad25b dracut-files.tbz2
|
||||||
|
adea715e719a4c460c41d8134aafa95b dracut-files.tbz2
|
||||||
|
c7e9dd35476cb33f09f22037f6c16982 dracut-files.tbz2
|
||||||
|
Loading…
Reference in New Issue
Block a user