diff --git a/kdump.conf b/00-default.conf similarity index 100% rename from kdump.conf rename to 00-default.conf diff --git a/Makefile b/Makefile index 24de2f8..7e54172 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/kdump-collect.sh b/kdump-collect.sh index 08d2ce0..488f277 100644 --- a/kdump-collect.sh +++ b/kdump-collect.sh @@ -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") diff --git a/kdump-load.sh b/kdump-load.sh index 0fbab0c..39045f0 100644 --- a/kdump-load.sh +++ b/kdump-load.sh @@ -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)" diff --git a/module-setup.sh b/module-setup.sh index 3fc2c3d..75016d1 100644 --- a/module-setup.sh +++ b/module-setup.sh @@ -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" } diff --git a/save-dumps.sh b/save-dumps.sh index 2a55def..a4fc039 100644 --- a/save-dumps.sh +++ b/save-dumps.sh @@ -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}"