all: Allow multiple config files

This is somewhat an intrusive change, but necessary if we want
to upstream the kdump tooling while allowing great extent of
customizations on SteamOS.

With this change, we have now a kdump.d folder on /usr/share,
that holds configuration files in the same way sysctl.d does.
In other words, we can easily override default settings by
just having more configuration files, which are sourced
following natural name sorting, i.e., we have now the concept
of config file precedence in kdump.

Our default config file is called 00-default, so we eventually
might have a 01-steamos e.g., with Deck's custom settings.
This is planned to other package though.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
This commit is contained in:
Guilherme G. Piccoli
2022-11-24 19:29:18 -03:00
parent ab0e82aed6
commit 184217373b
6 changed files with 55 additions and 25 deletions

View File

@ -20,4 +20,4 @@ install: all
install -D -m0644 README.md $(DESTDIR)$(dracutmodulesdir)/55kdump/README
install -D -m0755 kdump-load.sh $(DESTDIR)$(libdir)/kdump/kdump-load.sh
install -D -m0755 save-dumps.sh $(DESTDIR)$(libdir)/kdump/save-dumps.sh
install -D -m0644 kdump.conf $(DESTDIR)$(sharedir)/kdump/kdump.conf
install -D -m0644 00-default.conf $(DESTDIR)$(sharedir)/kdump.d/00-default

View File

@ -13,7 +13,13 @@
# output for the user.
#
. /usr/lib/kdump/kdump.conf
# We have a more controlled situation with regards the config
# files here, since we manually added them in the initrd and
# the validation also happened there, during such addition,
# hence not requiring checking here.
for cfg in "/usr/lib/kdump/conf/"/*; do
. "$cfg"
done
VMCORE="/proc/vmcore"
KDUMP_TIMESTAMP=$(date -u +"%Y%m%d%H%M")

View File

@ -78,14 +78,22 @@ cleanup_unused_initrd() {
rm -f "${INSTALLED_KERNELS}"
}
# Load the necessary external variables, otherwise it'll fail later.
HAVE_CFG_FILES=0
shopt -s nullglob
for cfg in "/usr/share/kdump.d"/*; do
if [ -f "$cfg" ]; then
. "$cfg"
HAVE_CFG_FILES=1
fi
done
shopt -u nullglob
if [ ! -s "/usr/share/kdump/kdump.conf" ]; then
logger "kdump: /usr/share/kdump/kdump.conf is missing, aborting."
exit 0
if [ ${HAVE_CFG_FILES} -eq 0 ]; then
logger "kdump: no config files in /usr/share/kdump.d/ - aborting."
exit 1
fi
. /usr/share/kdump/kdump.conf
# Find the proper mount point expected for kdump collection:
DEVN_MOUNTED="$(findmnt "${MOUNT_DEVNODE}" -fno TARGET)"

View File

@ -19,20 +19,12 @@ installkernel() {
}
install() {
# Having a valid /usr/share/kdump/kdump.conf is essential for kdump.
if [ ! -s "/usr/share/kdump/kdump.conf" ]; then
logger "kdump: failed to create initrd, kdump.conf is missing"
exit 1
fi
# Also true for makedumpfile...
# A valid makedumpfile is essential for the kdump initrd creation.
if [ ! -x "$(command -v makedumpfile)" ]; then
logger "kdump: failed to create initrd, makedumpfile is missing"
exit 1
fi
. /usr/share/kdump/kdump.conf
# First clear all unnecessary firmwares/drivers added by drm in order to
# reduce the size of this minimal initramfs being created. This should
# be already done via command-line arguments, but let's play safe and delete
@ -45,7 +37,25 @@ install() {
inst sync
inst makedumpfile
mkdir -p "$initdir"/usr/lib/kdump
mkdir -p "$initdir"/usr/lib/kdump/conf
# Load the necessary external variables, otherwise it'll fail later.
HAVE_CFG_FILES=0
shopt -s nullglob
for cfg in "/usr/share/kdump.d"/*; do
if [ -f "$cfg" ]; then
. "$cfg"
HAVE_CFG_FILES=1
fi
done
shopt -u nullglob
if [ ${HAVE_CFG_FILES} -eq 0 ]; then
logger "kdump: no config files in /usr/share/kdump.d/ - aborting."
exit 1
fi
cp -LR --preserve=all "/usr/share/kdump.d"/* "$initdir"/usr/lib/kdump/conf/
# Determine the numerical devnode for kdump, and save it on initrd;
# notice that partset link is not available that early in boot time.
@ -53,7 +63,6 @@ install() {
echo "${DEVN}" > "$initdir"/usr/lib/kdump/kdump.devnode
cp -LR --preserve=all /usr/lib/kdump/* "$initdir"/usr/lib/kdump/
cp -LR --preserve=all /usr/share/kdump/kdump.conf "$initdir"/usr/lib/kdump/kdump.conf
inst_hook pre-mount 01 "$moddir/kdump-collect.sh"
}

View File

@ -9,14 +9,21 @@
# collected data and save it in the local disk, in the next successful boot.
#
# We do some validation to be sure KDUMP_MNT pointed path is valid...
# That and having a valid /usr/share/kdump/kdump.conf are essential conditions.
if [ ! -s "/usr/share/kdump/kdump.conf" ]; then
logger "kdump: /usr/share/kdump/kdump.conf is missing, aborting."
exit 0
fi
# Load the necessary external variables, otherwise it'll fail later.
HAVE_CFG_FILES=0
shopt -s nullglob
for cfg in "/usr/share/kdump.d"/*; do
if [ -f "$cfg" ]; then
. "$cfg"
HAVE_CFG_FILES=1
fi
done
shopt -u nullglob
. /usr/share/kdump/kdump.conf
if [ ${HAVE_CFG_FILES} -eq 0 ]; then
logger "kdump: no config files in /usr/share/kdump.d/ - aborting."
exit 1
fi
KDUMP_MAIN_FOLDER="$(cat "${KDUMP_MNT}")"
rm -f "${KDUMP_MNT}"