File: /var/lib/dpkg/info/kdump-tools.postinst
#! /bin/sh
set -e
update_param() {
. "$INITCONFFILE"
# shellcheck disable=SC2086
eval old=\"'$'$1\"
# shellcheck disable=SC2086
eval new=\"'$'new_$1\"
if test "${old-}" = "${new-}"; then
return
fi
if test -z "$old"; then
grep -Eq "^ *$1=" "$INITCONFFILE" || echo "$1=" \
>> "$INITCONFFILE"
fi
sed -e "s/^ *$1=.*/$1=$new/" < "$INITCONFFILE" > "$INITCONFFILE.$$"
mv -f "$INITCONFFILE.$$" "$INITCONFFILE"
}
ZIPL_CONFFILE="/etc/zipl.conf"
update_zipl() {
if [ ! -f "${ZIPL_CONFFILE}" ]; then
return;
fi
TMPCONF=$(mktemp)
cp "${ZIPL_CONFFILE}" "${TMPCONF}"
CRASHKERNEL="${1}"
HAS_CRASHKERNEL="$(grep -q crashkernel "${TMPCONF}")" || true
if test -z "${HAS_CRASHKERNEL}"; then
sed -i "s|^\\s*parameters\\s*=\\s*\"\\?|&crashkernel=${CRASHKERNEL} |" "${TMPCONF}"
else
sed -i "s/crashkernel=[^[:space:]\"]*/crashkernel=${CRASHKERNEL}/" "${TMPCONF}"
fi
ucf --debconf-ok "${TMPCONF}" "${ZIPL_CONFFILE}"
rm -f "${TMPCONF}"
if [ -e /usr/sbin/zipl ]; then
/usr/sbin/zipl
fi
}
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
# ------------------------- Debconf questions start ---------------------
# Handle debconf
. /usr/share/debconf/confmodule
db_get kdump-tools/use_kdump || RET=true
if [ "${RET}" = "true" ]; then
# new_USE_KDUMP is used in update_param
# shellcheck disable=SC2034
new_USE_KDUMP="1"
else
# shellcheck disable=SC2034
new_USE_KDUMP="0"
fi
# ------------------------- Debconf questions end ---------------------
INITCONFFILE=$(mktemp /etc/default/kdump-tools.XXXXXX)
cp -pf /usr/share/kdump-tools/kdump-tools.conf "$INITCONFFILE"
update_param USE_KDUMP
# Customize crashkernel= value according to architecture
ARCH="$(arch)"
case "$ARCH" in
s390x)
CRASHKERNEL="2G-4G:320M,4G-32G:512M,32G-64G:1024M,64G-128G:2048M,128G-:4096M"
update_zipl "${CRASHKERNEL}"
CIO_IGNORE="$(cio_ignore -u -k)"
sed -i "s/\\#KDUMP_CMDLINE_APPEND/KDUMP_CMDLINE_APPEND/" "$INITCONFFILE"
sed -i "/KDUMP_CMDLINE_APPEND/{s|\"$| ${CIO_IGNORE}\"|}" "$INITCONFFILE"
;;
esac
ucfr kdump-tools /etc/default/kdump-tools
UCF_FORCE_CONFFMISS=1 ucf --debconf-ok "$INITCONFFILE" /etc/default/kdump-tools
rm -f "$INITCONFFILE"
sync /etc/default/kdump-tools
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
if command -v update-grub > /dev/null && [ -e /boot/grub/grub.cfg ]; then
update-grub
fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_installdeb/13.6ubuntu1
dpkg-maintscript-helper mv_conffile /etc/default/grub.d/kdump-tools.default /etc/default/grub.d/kdump-tools.cfg 1:1.6.1-2\~ kdump-tools -- "$@"
dpkg-maintscript-helper rm_conffile /etc/default/grub.d/kdump-tools..ppc64el 1:1.6.1-2\~ kdump-tools -- "$@"
# End automatically added section
# Automatically added by dh_installinit/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/kdump-tools" ]; then
update-rc.d kdump-tools defaults >/dev/null
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
invoke-rc.d --skip-systemd-native kdump-tools $_dh_action || exit 1
fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask 'kdump-tools.service' >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled 'kdump-tools.service'; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable 'kdump-tools.service' >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state 'kdump-tools.service' >/dev/null || true
fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
deb-systemd-invoke $_dh_action 'kdump-tools-dump.service' 'kdump-tools.service' >/dev/null || true
fi
fi
# End automatically added section
exit 0