#!/bin/sh # # kdump-tools will selectively override sysctls on kdump boot based in # the sysctl settings present on file /etc/kdump/sysctl.conf. # Only kdump minimal initrd contains this script - regular initrds won't # get this script included, since KDUMP variable is not set by default. # # Well....this is not entirely true in Debian. Due to initramfs-tools # on Debian lacking the OPTION=VAR feature (present in Ubuntu) to # control which scripts get included in initrd (based on the OPTION # value), this script *will* be included in regular initrd also. # But we have a check below to prevent it from doing the sysctls # overriding. We chose to kept the innocuous OPTION here to better # code sync with Ubuntu. # shellcheck disable=SC2034 OPTION=KDUMP set +e case "${1}" in prereqs) exit 0 ;; esac # In Debian we don't have the fine-tuned control of what scripts should # be included in the initrd based on OPTION=VAR (like Ubuntu). So, we # need the folowing check in order to prevent this script from running # on regular initrds - it should only be executed on kdump boot. VMCORE_FILE=/proc/vmcore if [ ! -e $VMCORE_FILE ]; then exit 0 fi KDUMP_SYSCTL_PATH="/etc/kdump/sysctl.conf" # Do not prevent the system boot on error, kdump may be the last resource! if [ ! -d /run ]; then echo "WARNING: kdump-sysctl needs /run available in order to work" exit 0 fi RT="${rootmnt?}" SYSD="sysctl.d/" FNAME="$(find "${RT}/usr/lib/${SYSD}" "${RT}/usr/local/lib/${SYSD}" "${RT}/lib/${SYSD}" "${RT}/etc/${SYSD}" "${RT}/run/${SYSD}" \ -maxdepth=1 -name '*.conf' -printf '%f\n' 2>/dev/null | LC_ALL=C sort | tail -n1)" FNAME="${FNAME}-kdump.conf" if [ ! -f ${KDUMP_SYSCTL_PATH} ]; then echo "WARNING: kdump-sysctl needs ${KDUMP_SYSCTL_PATH} on initrd to continue" exit 0 fi mkdir -p /run/sysctl.d cp -p ${KDUMP_SYSCTL_PATH} "/run/sysctl.d/${FNAME}"