mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Since version 198 (Feb 2013) systemd contains kernel-install, a script managing kernel installs. This script allows execution of drop-in scripts for customization. Add such a drop-in script to s390-tools to handle the installation of zfcpdump kernels. It's main purpose is to manage a link to the latest installed zfcpudump kernel at ZFCPDUMP_IMAGE, where zipl expects to find the image to install for a SCSI dumper. The script supports two installation modes. One recommended by the BootLoaderSpecs [1] to /boot/<machine-id>/<kernel-version> directories and one directly to /boot. In the second case files are renamed during installation to <original-name>-<kernel-version> to guarantee unique names. Because the zfcpdump kernel is so special make the script stand-alone and prevent any other script from being executed (exit 77) when a zfcpdump is installed. Especially avoid functionality like creating an initrd (already provided by s390-tools) or creating a boot entry (the zfcpdump kernel should not be used for any other purpose than dumping). The script requires systemd >= 203. [1] https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ Signed-off-by: Philipp Rudo <prudo@linux.ibm.com> Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
115 lines
3.0 KiB
Bash
Executable File
115 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# 10-zfcpdump.install - Installation script to handle zfcpdump kernels
|
|
#
|
|
# Copyright IBM Corp. 2018
|
|
#
|
|
# s390-tools is free software; you can redistribute it and/or modify
|
|
# it under the terms of the MIT license. See LICENSE for details.
|
|
#
|
|
#
|
|
# This script supports two modes:
|
|
#
|
|
# 1) Installing the images to /boot/<machine-id>/<kernel-version>
|
|
# subdirectories, i.e. BOOT_DIR_ABS, as recommended by the BLS.
|
|
# In this case file names are taken over from the original files.
|
|
#
|
|
# 2) Installing the images directly to /boot. In this case the files are
|
|
# renamed to <original-name>-<kernel-version>.
|
|
#
|
|
# The existence of BOOT_DIR_ABS is taken as trigger to switch between both
|
|
# modes.
|
|
#
|
|
# The KERNEL_VERSION is assumed to contain '@flavor@' to identify the image
|
|
# as a zfcpdump kernel.
|
|
|
|
COMMAND="$1"
|
|
KERNEL_VERSION="$2"
|
|
BOOT_DIR_ABS="$3"
|
|
KERNEL_IMAGE="$4"
|
|
|
|
# Location zipl looks for the zfcpdump kernel
|
|
ZFCPDUMP_IMAGE='@zfcpdump_image@'
|
|
|
|
# Only handle zfcpdump kernels
|
|
echo "$KERNEL_VERSION" | grep -q '@flavor@' || exit 0
|
|
|
|
case "$COMMAND" in
|
|
add)
|
|
KERNEL_DIR="$(dirname $KERNEL_IMAGE)"
|
|
KERNEL_NAME="$(basename $KERNEL_IMAGE)"
|
|
|
|
for f in \
|
|
"$KERNEL_IMAGE" \
|
|
"$KERNEL_DIR"/System.map \
|
|
"$KERNEL_DIR"/config \
|
|
"$KERNEL_DIR"/zImage.stub
|
|
do
|
|
test -e "$f" || continue
|
|
test -d "$BOOT_DIR_ABS" \
|
|
&& DEST="$BOOT_DIR_ABS/$(basename $f)" \
|
|
|| DEST="/boot/$(basename $f)-$KERNEL_VERSION"
|
|
|
|
cp -aT "$f" "$DEST"
|
|
test $(command -v restorecon) && restorecon -R "$DEST"
|
|
done
|
|
|
|
# hmac file need special treatment
|
|
f="$KERNEL_DIR/.$KERNEL_NAME.hmac"
|
|
if [ -e "$f" ]; then
|
|
test -d "$BOOT_DIR_ABS" \
|
|
&& DEST="$BOOT_DIR_ABS/$(basename $f)" \
|
|
|| DEST="/boot/.$KERNEL_NAME-$KERNEL_VERSION.hmac"
|
|
|
|
cp -aT "$f" "$DEST"
|
|
test $(command -v restorecon) && restorecon -R "$DEST"
|
|
fi
|
|
|
|
# Set link so zipl finds the kernel
|
|
test -d "$BOOT_DIR_ABS" \
|
|
&& TARGET="$BOOT_DIR_ABS/$KERNEL_NAME" \
|
|
|| TARGET="/boot/$KERNEL_NAME-$KERNEL_VERSION"
|
|
ln -sf "$TARGET" "$ZFCPDUMP_IMAGE"
|
|
;;
|
|
|
|
remove)
|
|
# On removal
|
|
# $KERNEL_IMAGE is empty -> $KERNEL_NAME is empty -> rebuild it
|
|
KERNEL_NAME="$(basename $(readlink $ZFCPDUMP_IMAGE))"
|
|
if [ -d "$BOOT_DIR_ABS" ]; then
|
|
INSTALL_DIR="$(dirname $BOOT_DIR_ABS)"
|
|
else
|
|
INSTALL_DIR="/boot/"
|
|
KERNEL_NAME="$(echo $KERNEL_NAME \
|
|
| sed -e "s#\(.*\)-$KERNEL_VERSION#\1#")"
|
|
fi
|
|
|
|
for f in $(find "$INSTALL_DIR" -name "*$KERNEL_VERSION*"); do
|
|
rm -rf "$f"
|
|
done
|
|
|
|
# Update link to latest remaining zfcpdump kernel.
|
|
if [ $(readlink "$ZFCPDUMP_IMAGE" | grep "$KERNEL_VERSION") ]
|
|
then
|
|
NEXT_IMAGE=$( \
|
|
find "$INSTALL_DIR" -type f \
|
|
| grep '@flavor@' \
|
|
| grep "$KERNEL_NAME" \
|
|
| grep -v "hmac" \
|
|
| sort -V \
|
|
| tail -n1 )
|
|
|
|
test $NEXT_IMAGE \
|
|
&& ln -sf "$NEXT_IMAGE" "$ZFCPDUMP_IMAGE" \
|
|
|| rm -f "$ZFCPDUMP_IMAGE"
|
|
fi
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
|
|
# Prevent execution of all other scripts.
|
|
# The zfcpdump kernel is stripped down to the bare minimum needed for
|
|
# dumping. It is not supposed to be used for any other purpose.
|
|
exit 77
|