Merge kdump-error-handler.sh into kdump.sh

kdump-error-handler.sh does nothing except calling three functions,
it can be easily merged into kdump.sh by using a parameter to run the
error handling routine.

kdump-lib-initramfs.sh was created to hold the three shared functions
and related code, so by merging these two files, kdump-lib-initramfs.sh
can be simplified by a lot.

Following up commits will clean up kdump-lib-initramfs.sh.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Kairui Song 2021-08-02 00:50:22 +08:00
parent a5faa052d4
commit e7118d1de8
5 changed files with 17 additions and 19 deletions

View File

@ -12,7 +12,7 @@ Environment=HOME=/
Environment=DRACUT_SYSTEMD=1 Environment=DRACUT_SYSTEMD=1
Environment=NEWROOT=/sysroot Environment=NEWROOT=/sysroot
WorkingDirectory=/ WorkingDirectory=/
ExecStart=/bin/kdump-error-handler.sh ExecStart=/bin/kdump.sh --error-handler
ExecStopPost=-/bin/rm -f -- /.console_lock ExecStopPost=-/bin/rm -f -- /.console_lock
Type=oneshot Type=oneshot
StandardInput=tty-force StandardInput=tty-force

View File

@ -1,10 +0,0 @@
#!/bin/sh
. /lib/kdump-lib-initramfs.sh
set -o pipefail
export PATH=$PATH:$KDUMP_SCRIPT_DIR
get_kdump_confs
do_failure_action
do_final_action

View File

@ -1,9 +1,7 @@
#!/bin/sh #!/bin/sh
#
# continue here only if we have to save dump. # The main kdump routine in capture kernel
if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then #
exit 0
fi
. /lib/dracut-lib.sh . /lib/dracut-lib.sh
. /lib/kdump-lib-initramfs.sh . /lib/kdump-lib-initramfs.sh
@ -288,6 +286,19 @@ fence_kdump_notify()
fi fi
} }
if [ "$1" = "--error-handler" ]; then
get_kdump_confs
do_failure_action
do_final_action
exit $?
fi
# continue here only if we have to save dump.
if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
exit 0
fi
read_kdump_confs read_kdump_confs
fence_kdump_notify fence_kdump_notify

View File

@ -1039,7 +1039,6 @@ install() {
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service
inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh"
# Replace existing emergency service and emergency target # Replace existing emergency service and emergency target
cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service"
cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target" cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target"

View File

@ -52,7 +52,6 @@ Source36: kdump-restart.sh
Source100: dracut-kdump.sh Source100: dracut-kdump.sh
Source101: dracut-module-setup.sh Source101: dracut-module-setup.sh
Source102: dracut-monitor_dd_progress Source102: dracut-monitor_dd_progress
Source103: dracut-kdump-error-handler.sh
Source104: dracut-kdump-emergency.service Source104: dracut-kdump-emergency.service
Source106: dracut-kdump-capture.service Source106: dracut-kdump-capture.service
Source107: dracut-kdump-emergency.target Source107: dracut-kdump-emergency.target
@ -241,7 +240,6 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba
cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}}
cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}}
cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}}
cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}}
cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}}
cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}}