diff --git a/00-default.conf b/00-default.conf index df49b64..1cd62d8 100644 --- a/00-default.conf +++ b/00-default.conf @@ -7,7 +7,7 @@ # # Configuration settings for kdump/pstore. After _any_ change in this # file, it's required to re-create the kdump minimal initramfs by running: -# /usr/lib/kdump/kdump-load.sh initrd +# /usr/lib/kdump/kdump-load.sh create-initrd # # # Pstore-RAM settings diff --git a/kdump-init.service b/kdump-init.service index 79a597d..c8f84ac 100644 --- a/kdump-init.service +++ b/kdump-init.service @@ -10,7 +10,7 @@ Description=pstore/kdump loader boot-time service [Service] Type=oneshot StandardOutput=journal -ExecStartPre=/usr/lib/kdump/kdump-load.sh +ExecStartPre=/usr/lib/kdump/kdump-load.sh load ExecStart=/usr/lib/kdump/save-dumps.sh RemainAfterExit=yes diff --git a/kdump-load.header b/kdump-load.header index e728cf9..e9f818e 100644 --- a/kdump-load.header +++ b/kdump-load.header @@ -1,5 +1,5 @@ #!/bin/bash -set -uo pipefail +set -o pipefail # Didn't set -u on purpose, since users could pass empty $1 # # SPDX-License-Identifier: LGPL-2.1+ # diff --git a/kdump-load.sh.in b/kdump-load.sh.in index deb9114..656cd39 100644 --- a/kdump-load.sh.in +++ b/kdump-load.sh.in @@ -71,21 +71,60 @@ cleanup_unused_initrd() { rm -f "${INSTALLED_KERNELS}" } -load_kdump_config - -# In case the kdump main folder doesn't exist, create it -# here, as soon as possible. -mkdir -p "${MOUNT_FOLDER}" - -if [ "$1" = "initrd" ]; then - create_initrd - exit 0 -fi - -if [ "$1" = "clear" ]; then +# Now this routine performs a full deletion of all kdump initrd files. +clear_all_initrds() { rm -f "${MOUNT_FOLDER}"/kdump-initrd-* - exit 0 -fi +} + +# Function to display basic help about how to use this tool. +usage() { + cat < +Kdump/Pstore loader. + +Options: + load + Load pstore/kdump according to the configuration file. + + create-initrd + Create the minimal kdump initrd for the running kernel. + + clear-initrd + Delete all kdump minimal initrd images. +EOF +} + +preamble() { + load_kdump_config + + # In case the kdump main folder doesn't exist, create it + # here, as soon as possible. + mkdir -p "${MOUNT_FOLDER}" +} + +# Entry point of the script. +case $1 in + clear-initrd) + preamble + clear_all_initrds + exit 0 + ;; + create-initrd) + preamble + create_initrd + exit 0 + ;; + load) + # just bail from the case statement, jumping to code below + ;; + *) + usage + exit 1 + ;; +esac + +# Here starts the main purpose of this script, the load operation. +preamble # Pstore-RAM load; if it is configured via the config files and fails # to configure pstore, we still try to load the kdump. We try to reserve