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:
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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+
|
||||
#
|
||||
|
||||
@ -71,21 +71,60 @@ cleanup_unused_initrd() {
|
||||
rm -f "${INSTALLED_KERNELS}"
|
||||
}
|
||||
|
||||
# Now this routine performs a full deletion of all kdump initrd files.
|
||||
clear_all_initrds() {
|
||||
rm -f "${MOUNT_FOLDER}"/kdump-initrd-*
|
||||
}
|
||||
|
||||
# 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}"
|
||||
}
|
||||
|
||||
if [ "$1" = "initrd" ]; then
|
||||
# Entry point of the script.
|
||||
case $1 in
|
||||
clear-initrd)
|
||||
preamble
|
||||
clear_all_initrds
|
||||
exit 0
|
||||
;;
|
||||
create-initrd)
|
||||
preamble
|
||||
create_initrd
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
load)
|
||||
# just bail from the case statement, jumping to code below
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$1" = "clear" ]; then
|
||||
rm -f "${MOUNT_FOLDER}"/kdump-initrd-*
|
||||
exit 0
|
||||
fi
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user