kdump-load: Add usage/help messages to this script

The kdump-load script is the only one that has more than a
single functionality, potentially being invoked in different ways.

With that in mind, just add a small usage/help for users'
information (thanks Emil for the suggestion).

While at it, changed the additional commands to be more friendly
and require exactly one command to be passed - changes summary:
s/initrd/create-initrd
s/clear/clear-initrd
s//load

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
This commit is contained in:
Guilherme G. Piccoli
2022-12-28 15:44:49 -03:00
parent a3ab8c421b
commit e24d6d9b46
4 changed files with 56 additions and 17 deletions

View File

@ -7,7 +7,7 @@
# #
# Configuration settings for kdump/pstore. After _any_ change in this # Configuration settings for kdump/pstore. After _any_ change in this
# file, it's required to re-create the kdump minimal initramfs by running: # 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 # Pstore-RAM settings

View File

@ -10,7 +10,7 @@ Description=pstore/kdump loader boot-time service
[Service] [Service]
Type=oneshot Type=oneshot
StandardOutput=journal StandardOutput=journal
ExecStartPre=/usr/lib/kdump/kdump-load.sh ExecStartPre=/usr/lib/kdump/kdump-load.sh load
ExecStart=/usr/lib/kdump/save-dumps.sh ExecStart=/usr/lib/kdump/save-dumps.sh
RemainAfterExit=yes RemainAfterExit=yes

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/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+ # SPDX-License-Identifier: LGPL-2.1+
# #

View File

@ -71,21 +71,60 @@ cleanup_unused_initrd() {
rm -f "${INSTALLED_KERNELS}" rm -f "${INSTALLED_KERNELS}"
} }
load_kdump_config # Now this routine performs a full deletion of all kdump initrd files.
clear_all_initrds() {
# 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
rm -f "${MOUNT_FOLDER}"/kdump-initrd-* rm -f "${MOUNT_FOLDER}"/kdump-initrd-*
exit 0 }
fi
# Function to display basic help about how to use this tool.
usage() {
cat <<EOF
${0##*/} <COMMAND>
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 # 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 # to configure pstore, we still try to load the kdump. We try to reserve