tags 856596 + patch
thanks

Hi,

attached are six patches to make kdump-config & makedumpfile work (at
least for our kdump-tools configuration). Please review these patches
and let me know what you think about them.

-- 
Benjamin Drung
System Developer
Debian & Ubuntu Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Email: benjamin.dr...@profitbricks.com
URL:  http://www.profitbricks.com

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
From 91bf7d557cb5535d5c15794f80cecf37385ab540 Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Fri, 3 Mar 2017 19:34:15 +0100
Subject: [PATCH 1/6] kdump-config: Replace "hostname -I" by ip addr

busybox's hostname command does not support the -I parameter.
Thus replace it by a call to ip addr instead.

Related Debian bug: #856596
---
 debian/kdump-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index da0abd1..a7b852c 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -624,7 +624,7 @@ function define_stampdir()
 		# Looping to give time to network to settle
 		typeset -i counter=0
 		while (( counter < 5));do
-			THIS_HOST="$(hostname -I)"
+			THIS_HOST="$(ip addr show up | grep -w inet | tail -n1 | awk '{print $2}' | cut -f1  -d'/')"
 			set -- $THIS_HOST
 			THIS_HOST=$1
 			if [ -z "$THIS_HOST" ]; then
-- 
2.9.3

From 26df92e3e2b755803527c32543834dbd58eaa95a Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Mon, 6 Mar 2017 13:57:10 +0100
Subject: [PATCH 2/6] kdump-config: Do not require kexec for all commands

The kexec binary is only needed for the load and unload command. Thus do
not require it for all calls.

Related Debian bug: #856596
---
 debian/kdump-config | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index a7b852c..41cd3c7 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -37,7 +37,6 @@ KDUMP_DEFAULTS=/etc/default/kdump-tools
 [ -r $KDUMP_DEFAULTS ] && . $KDUMP_DEFAULTS
 
 KEXEC=/sbin/kexec
-[ -e $KEXEC ] || exit 1;
 
 KVER=`uname -r`
 ARCH=`uname -m`
@@ -522,6 +521,8 @@ kernel_version=$1
 # Returns: none. prints warnings or exit
 function kdump_load()
 {
+	[ -e $KEXEC ] || exit 1
+
 	# assemble the kexec command used to load the kdump kernel
 	KEXEC_CMD="$KEXEC -p"
 
@@ -590,6 +591,8 @@ function kdump_load()
 # Returns: none. prints warnings or exit
 function kdump_unload()
 {
+	[ -e $KEXEC ] || exit 1
+
 	if check_secure_boot || check_securelevel; then
 		$KEXEC -s -p -u
 	else
-- 
2.9.3

From 3eb8d3137f3dc1b01552b5d432cd3b7ee5804d01 Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Mon, 6 Mar 2017 14:09:15 +0100
Subject: [PATCH 3/6] kdump-config: Remove sourcing /lib/init/vars.sh

None of the variables in /lib/init/vars.sh are used.

Related Debian bug: #856596
---
 debian/kdump-config | 1 -
 1 file changed, 1 deletion(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index 41cd3c7..ae02650 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -30,7 +30,6 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
 NAME=${NAME:="kdump-config"}
 
 . /lib/lsb/init-functions
-. /lib/init/vars.sh
 
 # Global Setup
 KDUMP_DEFAULTS=/etc/default/kdump-tools
-- 
2.9.3

From 4964971890c10bac5d629b58925356ab4dd9028e Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Mon, 6 Mar 2017 14:23:33 +0100
Subject: [PATCH 4/6] kdump-config: Run without /lib/lsb/init-functions

kdump-config uses the log functions from /lib/lsb/init-functions. Do not
require /lib/lsb/init-functions to be present.

Related Debian bug: #856596
---
 debian/kdump-config | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index ae02650..df54e35 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -29,7 +29,22 @@
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 NAME=${NAME:="kdump-config"}
 
-. /lib/lsb/init-functions
+if test -e /lib/lsb/init-functions; then
+	. /lib/lsb/init-functions
+else
+	log_action_msg() {
+		echo "$@."
+	}
+
+	log_failure_msg() {
+		echo "$@ failed!"
+		return 1
+	}
+
+	log_success_msg() {
+		echo "$@."
+	}
+fi
 
 # Global Setup
 KDUMP_DEFAULTS=/etc/default/kdump-tools
-- 
2.9.3

From 88b273cb99c7c211591bbd8dca63f4b7051c656e Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Mon, 6 Mar 2017 14:38:11 +0100
Subject: [PATCH 5/6] kdump-config: Use POSIX shell instead of bash

To reduce the footprint, replace bash by the standard shell.

Related Debian bug: #856596
---
 debian/kdump-config | 90 ++++++++++++++++++++++++++---------------------------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index df54e35..361b533 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # kdump-config
 # Copyright (C) 2007-2009 Hewlett-Packard Development Company, L.P.
@@ -88,7 +88,7 @@ fi
 
 # Utility Functions
 #
-function kdump_help()
+kdump_help()
 {
 cat <<EOHELP
 Usage:
@@ -115,13 +115,13 @@ kdump-config {help|test|show|status|load|unload|savecore|propagate|symlinks kern
 EOHELP
 }
 
-function kdump_show()
+kdump_show()
 {
 	echo "DUMP_MODE:        $DUMP_MODE"
 	echo "USE_KDUMP:        $USE_KDUMP"
 	echo "KDUMP_SYSCTL:     $KDUMP_SYSCTL"
 	echo "KDUMP_COREDIR:    $KDUMP_COREDIR"
-	if [ "$DUMP_MODE" == "kdump" ]; then
+	if [ "$DUMP_MODE" = "kdump" ]; then
 		echo "crashkernel addr: $IOMEM_ADDR"
 	fi
 	if [ -h "$KDUMP_KERNEL" ];then
@@ -164,7 +164,7 @@ function kdump_show()
 		echo "HOSTTAG:          $HOSTTAG"
 	fi
 
-	if [ "$DUMP_MODE" == "fadump" ]; then
+	if [ "$DUMP_MODE" = "fadump" ]; then
 		if [ -e $sys_fadump_registered ] &&
 			[ `cat $sys_fadump_registered` -eq 1 ] ; then
 			echo "current state:    ready to fadump";
@@ -189,7 +189,7 @@ function kdump_show()
 	fi
 }
 
-function kdump_test()
+kdump_test()
 {
 	echo "USE_KDUMP:         $USE_KDUMP"
 	echo "KDUMP_SYSCTL:      $KDUMP_SYSCTL"
@@ -217,7 +217,7 @@ function kdump_test()
 # is used to store smaller initrd.img files (Ubuntu only)
 # Returns: 0/1 (success/broken,absent or wrong version)
 #
-function check_symlink()
+check_symlink()
 {
 symlink=$1
 kern_version=$2
@@ -226,12 +226,12 @@ kern_version=$2
 		linkedfile=$(file "$KDUMP_DIR/$symlink" | rev | cut -d" " -f1 | rev)
 		if [ -e "$linkedfile" ];then
 			version=$(basename $linkedfile)
-			if [ ${version%%-*} == "vmlinux" ];then
+			if [ ${version%%-*} = "vmlinux" ];then
 				version=${version#vmlinux-}
 			else
 				version=${version#$symlink-}
 			fi
-			if [ ${version} == $kern_version ]; then
+			if [ ${version} = $kern_version ]; then
 				return 0
 			fi
 		fi
@@ -240,13 +240,13 @@ kern_version=$2
 }
 
 # Create a symlink
-function create_symlink()
+create_symlink()
 {
 link=$1
 kernel_version=$2
 
 	log_action_msg "Creating symlink $KDUMP_DIR/${link}"
-	if [ $link == "vmlinuz" ];then
+	if [ $link = "vmlinuz" ];then
 		ln -fs /boot/${link%?}?-${kernel_version} $KDUMP_DIR/$link
 	else
 		ln -fs $KDUMP_DIR/${link}-${kernel_version} $KDUMP_DIR/$link
@@ -262,13 +262,13 @@ kernel_version=$2
 # is done.
 # Returns: none. prints warnings or exit
 # Creates: $KDUMP_DIR/vmlinuz $KDUMP_DIR/initrd.img
-function manage_symlinks()
+manage_symlinks()
 {
 	if [ -d "$KDUMP_DIR" ];then
 		for symlink in initrd.img vmlinuz;do
 			check_symlink $symlink $KVER
 			ret=$?
-			if [ $ret == 1 ];then
+			if [ $ret -eq 1 ];then
 				log_failure_msg "Invalid symlink : $KDUMP_DIR/$symlink"
 				if [ ! $DRY_RUN ];then
 					create_symlink $symlink $KVER
@@ -285,9 +285,9 @@ function manage_symlinks()
 #    thinks it supports fadump
 #
 # Returns: none. prints warnings or exit
-function check_fadump_support()
+check_fadump_support()
 {
-	if [ -z "$USE_KDUMP" -o "$USE_KDUMP" == "0" ] ; then
+	if [ -z "$USE_KDUMP" -o "$USE_KDUMP" = "0" ] ; then
 		log_failure_msg "$KDUMP_DEFAULTS: USE_KDUMP is not set or zero"
 		[ ! $DRY_RUN ] && exit 1;
 	fi
@@ -318,9 +318,9 @@ function check_fadump_support()
 #    line parameter.
 #
 # Returns: none. prints warnings or exit
-function check_kdump_support()
+check_kdump_support()
 {
-	if [ -z "$USE_KDUMP" -o "$USE_KDUMP" == "0" ] ; then
+	if [ -z "$USE_KDUMP" -o "$USE_KDUMP" = "0" ] ; then
 		log_failure_msg "$KDUMP_DEFAULTS: USE_KDUMP is not set or zero"
 		[ ! $DRY_RUN ] && exit 1;
 	fi
@@ -344,7 +344,7 @@ function check_kdump_support()
 #   1: the config file to check
 # Returns: 0 if the given kernel config indicates a relocatable kernel.
 #          1 otherwise.
-function check_relocatable()
+check_relocatable()
 {
 	if [ "$ARCH" = "ia64" ]; then
 		# Linux is always relocatable on ia64
@@ -356,7 +356,7 @@ function check_relocatable()
 	fi
 }
 
-function check_securelevel()
+check_securelevel()
 {
 	local sl_path="/sys/kernel/security/securelevel"
 	if [ ! -f "$sl_path" ]; then
@@ -371,7 +371,7 @@ function check_securelevel()
 }
 
 
-function check_secure_boot()
+check_secure_boot()
 {
 	local sb_path sm_file sb sm
 
@@ -401,7 +401,7 @@ function check_secure_boot()
 # Returns: 0/1 (success/fail)
 # Returns: none. prints warnings or exit
 # Sets:    KDUMP_KERNEL, KDUMP_INITRD
-function locate_kdump_kernel()
+locate_kdump_kernel()
 {
 	# 1:  User may have specified the KDUMP_KERNEL and KDUMP_INITRD 
 	#     explicitly.   Test for existance and either use it or fail.
@@ -457,7 +457,7 @@ function locate_kdump_kernel()
 
 # Register firmware-assisted dump as the dump mechanism
 # Returns: none. prints warnings or exit
-function fadump_register()
+fadump_register()
 {
 	# set fadump registered sys node to `1` to register fadump
 	if [ "`cat $sys_fadump_registered`" -ne 1 ]; then
@@ -481,7 +481,7 @@ function fadump_register()
 }
 
 # Returns: none. prints warnings or exit
-function fadump_unregister()
+fadump_unregister()
 {
 	# set fadump registered sys node to `0` to un-register fadump
 	if [ "`cat $sys_fadump_registered`" -ne 0 ]; then
@@ -498,7 +498,7 @@ function fadump_unregister()
 	logger -t $NAME "fadump un-registered successfully"
 }
 
-function kdump_create_symlinks()
+kdump_create_symlinks()
 {
 kernel_version=$1
 
@@ -533,7 +533,7 @@ kernel_version=$1
 #			c. append KDUMP_CMDLINE_APPEND from defaults file
 # Sets:    KEXEC_CMD
 # Returns: none. prints warnings or exit
-function kdump_load()
+kdump_load()
 {
 	[ -e $KEXEC ] || exit 1
 
@@ -583,7 +583,7 @@ function kdump_load()
 
 	eval $KEXEC_CMD
 
-	if [ $? == 0 ]; then
+	if [ $? -eq 0 ]; then
 		log_success_msg "loaded kdump kernel"
 		logger -t $NAME "$KEXEC_CMD"
 		logger -t $NAME "loaded kdump kernel"
@@ -603,7 +603,7 @@ function kdump_load()
 }
 
 # Returns: none. prints warnings or exit
-function kdump_unload()
+kdump_unload()
 {
 	[ -e $KEXEC ] || exit 1
 
@@ -613,7 +613,7 @@ function kdump_unload()
 		$KEXEC -p -u
 	fi
 
-	if [ $? == 0 ]; then
+	if [ $? -eq 0 ]; then
 		log_success_msg "unloaded kdump kernel"
 		logger -t $NAME "unloaded kdump kernel"
 	else
@@ -628,7 +628,7 @@ function kdump_unload()
 #	Will add hostname/IP according to the value of
 #	HOSTTAG if networked dump is selected
 
-function define_stampdir()
+define_stampdir()
 {
 	STAMP=$1
 	HOSTTAG="${HOSTTAG:=ip}"
@@ -639,14 +639,14 @@ function define_stampdir()
 		echo "$KDUMP_COREDIR/$(hostname)-$STAMP"
 	else
 		# Looping to give time to network to settle
-		typeset -i counter=0
-		while (( counter < 5));do
+		local counter=0
+		while [ $counter -lt 5 ];do
 			THIS_HOST="$(ip addr show up | grep -w inet | tail -n1 | awk '{print $2}' | cut -f1  -d'/')"
 			set -- $THIS_HOST
 			THIS_HOST=$1
 			if [ -z "$THIS_HOST" ]; then
 				sleep 1
-				((counter+=1))
+				counter=$(($counter + 1))
 			else
 				break
 			fi
@@ -699,7 +699,7 @@ compression_extension() {
 #
 # Returns: 0/1 (success/fail)
 # Sets: KDUMP_STAMPDIR, KDUMP_COREFILE
-function kdump_save_core()
+kdump_save_core()
 {
 	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
 	KDUMP_STAMPDIR=$(define_stampdir $KDUMP_STAMP)
@@ -754,7 +754,7 @@ function kdump_save_core()
 	fi
 
 	# did we succeed?
-	if [ $ERROR == 0 ]; then
+	if [ $ERROR -eq 0 ]; then
 		mv $KDUMP_CORETEMP $KDUMP_COREFILE
 		log_success_msg "$NAME: saved vmcore in $KDUMP_STAMPDIR"
 		logger -t $NAME "saved vmcore in $KDUMP_STAMPDIR"
@@ -775,7 +775,7 @@ function kdump_save_core()
             fi
 
 	    # did we succeed?
-	    if [ $ERROR == 0 ]; then
+	    if [ $ERROR -eq 0 ]; then
 		log_success_msg "$NAME: saved dmesg content in $KDUMP_STAMPDIR"
 		logger -t $NAME "saved dmesg content in $KDUMP_STAMPDIR"
 		sync
@@ -786,7 +786,7 @@ function kdump_save_core()
 	fi
 
 	# limit the number of dumps kept on the local machine
-	if [ -z "${NFS}" -a $ERROR == 0 -a $KDUMP_NUM_DUMPS -gt 0 ] ; then
+	if [ -z "${NFS}" -a $ERROR -eq 0 -a $KDUMP_NUM_DUMPS -gt 0 ] ; then
 		num_dumps=$(ls -1dv $KDUMP_COREDIR/2* | wc -l)
 		if [ $num_dumps -gt $KDUMP_NUM_DUMPS ] ; then
 			purge_num=$((num_dumps - KDUMP_NUM_DUMPS))
@@ -880,7 +880,7 @@ kdump_save_core_to_ftp()
 	return $ERROR
 }
 
-function kdump_save_core_to_ssh()
+kdump_save_core_to_ssh()
 {
 	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
 	KDUMP_REMOTE_HOST="$SSH"
@@ -949,7 +949,7 @@ function kdump_save_core_to_ssh()
 	    fi
 
 	    # did we succeed?
-	    if [ $ERROR == 0 ]; then
+	    if [ $ERROR -eq 0 ]; then
 		    log_success_msg "$NAME: saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
 		    logger -t $NAME "saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
 		    return 0;
@@ -961,7 +961,7 @@ function kdump_save_core_to_ssh()
 	fi
 }
 
-function kdump_propagate()
+kdump_propagate()
 {
 	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
 	KDUMP_REMOTE_HOST="$SSH"
@@ -985,7 +985,7 @@ function kdump_propagate()
 	KDUMP_SSH_USER=${KDUMP_REMOTE_HOST%@*}
 	KDUMP_SSH_TARGET=${KDUMP_REMOTE_HOST#*@}
 
-	ssh-copy-id -i $KDUMP_SSH_KEY $KDUMP_SSH_USER@$KDUMP_SSH_TARGET &>/dev/null
+	ssh-copy-id -i $KDUMP_SSH_KEY $KDUMP_SSH_USER@$KDUMP_SSH_TARGET >/dev/null 2>&1
 	ERROR=$?
 
 	if [ $ERROR -ne 0 ];then
@@ -1005,7 +1005,7 @@ function kdump_propagate()
 case "$1" in
   test)
 	DRY_RUN="true"
-	if [ "$DUMP_MODE" == "fadump" ]; then
+	if [ "$DUMP_MODE" = "fadump" ]; then
 		check_fadump_support
 	else
 		check_kdump_support;
@@ -1017,7 +1017,7 @@ case "$1" in
 	;;
   show)
 	DRY_RUN="true"
-	if [ "$DUMP_MODE" == "fadump" ]; then
+	if [ "$DUMP_MODE" = "fadump" ]; then
 		check_fadump_support;
 	else
 		check_kdump_support;
@@ -1025,7 +1025,7 @@ case "$1" in
 	kdump_show
 	;;
   load)
-	if [ "$DUMP_MODE" == "fadump" ]; then
+	if [ "$DUMP_MODE" = "fadump" ]; then
 		check_fadump_support;
 		fadump_register
 	else
@@ -1036,14 +1036,14 @@ case "$1" in
 	fi
 	;;
   unload)
-	if [ "$DUMP_MODE" == "fadump" ]; then
+	if [ "$DUMP_MODE" = "fadump" ]; then
 		fadump_unregister
 	else
 		kdump_unload
 	fi
 	;;
   status)
-	if [ "$DUMP_MODE" == "fadump" ]; then
+	if [ "$DUMP_MODE" = "fadump" ]; then
 		check_fadump_support
 		if [ `cat $sys_fadump_registered` -eq 1 ] ; then
 			echo "current state   : ready to fadump";
-- 
2.9.3

From 307963c151fadda97b14523298f082426481ac8f Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Tue, 7 Mar 2017 11:23:51 +0100
Subject: [PATCH 6/6] Support self-contained initramfs

Closes: #856596
Signed-off-by: Benjamin Drung <benjamin.dr...@profitbricks.com>
---
 debian/initramfs-tools-hook            | 57 ++++++++++++++++++++++++++++++++++
 debian/initramfs-tools-script          | 53 +++++++++++++++++++++++++++++++
 debian/kdump-tools.default             |  4 +++
 debian/kernel-postinst-generate-initrd | 11 ++++++-
 debian/rules                           |  2 ++
 5 files changed, 126 insertions(+), 1 deletion(-)
 create mode 100755 debian/initramfs-tools-hook
 create mode 100755 debian/initramfs-tools-script

diff --git a/debian/initramfs-tools-hook b/debian/initramfs-tools-hook
new file mode 100755
index 0000000..f9ae0cb
--- /dev/null
+++ b/debian/initramfs-tools-hook
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+	echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+	prereqs
+	exit 0
+	;;
+esac
+
+. /usr/share/initramfs-tools/hook-functions
+
+mkdir -p $DESTDIR/usr/bin $DESTDIR/usr/sbin
+
+if test -e /etc/default/kdump-tools; then
+	install -m 644 -D /etc/default/kdump-tools $DESTDIR/etc/default/kdump-tools
+	. /etc/default/kdump-tools
+fi
+
+if test -e /usr/sbin/kdump-config; then
+	copy_exec /usr/sbin/kdump-config
+fi
+
+if command -v makedumpfile >/dev/null 2>&1; then
+	copy_exec /usr/bin/makedumpfile
+fi
+
+if test "$KDUMP_COMPRESSION" = "lz4"; then
+	if command -v lz4 >/dev/null 2>&1; then
+		copy_exec /usr/bin/lz4
+	fi
+fi
+
+if test "$KDUMP_COMPRESSION" = "xz"; then
+	if command -v lz4 >/dev/null 2>&1; then
+		copy_exec /usr/bin/xz
+	fi
+fi
+
+# libnss_dns is needed for resolving hosts by name
+if test -e /lib/x86_64-linux-gnu/libnss_dns.so.2; then
+	copy_exec /lib/x86_64-linux-gnu/libnss_dns.so.2
+fi
+
+# Support module configurations specifically for kdump's initramfs
+for file in /etc/kdump-tools/modprobe.d/*.conf; do
+	if test -e "$file"; then
+		cp -aL $file "${DESTDIR}/etc/modprobe.d/"
+	fi
+done
diff --git a/debian/initramfs-tools-script b/debian/initramfs-tools-script
new file mode 100755
index 0000000..cd52623
--- /dev/null
+++ b/debian/initramfs-tools-script
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+	echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+	prereqs
+	exit 0
+	;;
+esac
+
+. /scripts/functions
+
+ETH_DEV=$(ls /sys/bus/pci/drivers/igb | grep '\.0')
+if test -n "$ETH_DEV"; then
+	echo "Resetting igb driver for $ETH_DEV"
+	echo 1 > /sys/bus/pci/drivers/igb/$ETH_DEV/reset
+fi
+
+log_begin_msg "Starting networking"
+configure_networking || panic "Network configuration failed."
+log_end_msg
+
+# Setting up networking
+rm -f /etc/resolv.conf
+if test -n "$IPV4DNS0"; then
+	echo "nameserver $IPV4DNS0" >> /etc/resolv.conf
+fi
+if test -n "$IPV4DNS1"; then
+	echo "nameserver $IPV4DNS1" >> /etc/resolv.conf
+fi
+if test -n "$DOMAINSEARCH"; then
+	echo "search $DOMAINSEARCH" >> /etc/resolv.conf
+fi
+if test -n "$HOSTNAME"; then
+	echo "$HOSTNAME" > /etc/hostname
+	hostname -F /etc/hostname
+	if test -n "$DNSDOMAIN"; then
+		printf "127.0.0.1 localhost\n127.0.1.1 $HOSTNAME.$DNSDOMAIN $HOSTNAME\n" > /etc/hosts
+	fi
+fi
+
+log_begin_msg "Starting kdump"
+kdump-config savecore || panic "'kdump-config savecore' failed with exit code $?."
+log_end_msg
+
+panic "kdump done at $(date '+%Y-%m-%d %H:%M:%S %z'). You can reboot the system with 'reboot -f' now."
diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default
index 3d0648e..1a2d792 100644
--- a/debian/kdump-tools.default
+++ b/debian/kdump-tools.default
@@ -22,8 +22,12 @@ USE_KDUMP=1
 #     If these are not set, kdump-config will try to use the current kernel
 #     and initrd if it is relocatable.  Otherwise, you will need to specify
 #     these manually.
+# SELF_CONTAINED_INITRD - controls what the initrd contains
+#     0 - Use a minimal initrd to load the local file system (default)
+#     1 - Use a self-contained initrd that loads enough to call makedumpfile
 KDUMP_KERNEL=/var/lib/kdump/vmlinuz
 KDUMP_INITRD=/var/lib/kdump/initrd.img
+#SELF_CONTAINED_INITRD=0
 
 
 # ---------------------------------------------------------------------------
diff --git a/debian/kernel-postinst-generate-initrd b/debian/kernel-postinst-generate-initrd
index d22a62b..f5bae28 100755
--- a/debian/kernel-postinst-generate-initrd
+++ b/debian/kernel-postinst-generate-initrd
@@ -39,7 +39,16 @@ cp -pr /etc/initramfs-tools "$kdumpdir" || true
 
 initramfsdir="$kdumpdir/initramfs-tools"
 
-sed -e 's/MODULES=.*/MODULES=dep/' /etc/initramfs-tools/initramfs.conf > "$initramfsdir/initramfs.conf" || true
+if [ -e /etc/default/kdump-tools ]; then
+	. /etc/default/kdump-tools
+fi
+if [ "${SELF_CONTAINED_INITRD-}" = "1" ]; then
+	cp -pr /usr/share/kdump-tools/initramfs-tools "$kdumpdir" || true
+	sed -e 's/MODULES=.*/MODULES=netboot/' /etc/initramfs-tools/initramfs.conf > "$initramfsdir/initramfs.conf" || true
+else
+	sed -e 's/MODULES=.*/MODULES=dep/' /etc/initramfs-tools/initramfs.conf > "$initramfsdir/initramfs.conf" || true
+fi
+
 if ! [ -e "$initramfsdir/initramfs.conf" ];then
 	echo >&2 "W: kdump-tools: Unable to create $initramfsdir/initramfs.conf"
 	exit 2
diff --git a/debian/rules b/debian/rules
index 903f416..40b5397 100755
--- a/debian/rules
+++ b/debian/rules
@@ -20,6 +20,8 @@ override_dh_install:
 	dh_install
 	install -D -m 755 debian/kernel-postinst-generate-initrd debian/kdump-tools/etc/kernel/postinst.d/kdump-tools
 	install -D -m 755 debian/kernel-postrm-delete-initrd debian/kdump-tools/etc/kernel/postrm.d/kdump-tools
+	install -D -m 755 debian/initramfs-tools-hook debian/kdump-tools/usr/share/kdump-tools/initramfs-tools/hooks/kdump-tools
+	install -D -m 755 debian/initramfs-tools-script debian/kdump-tools/usr/share/kdump-tools/initramfs-tools/scripts/init-premount/kdump-tools
 ifneq (,$(filter $(DEB_HOST_ARCH),i386 amd64 powerpc ppc64 ppc64el ia64))
 	install -D -m 644 debian/kdump-tools.grub.default debian/kdump-tools/etc/default/grub.d/kdump-tools.default
 	install -D -m 644 debian/kdump-tools.grub.ppc64el debian/kdump-tools/etc/default/grub.d/kdump-tools..ppc64el
-- 
2.9.3

Reply via email to