|
Harald Hoyer |
f97365 |
From 819ea3865161d440353b2f961f3dfeaabeed333d Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
f97365 |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
f97365 |
Date: Thu, 26 Jul 2018 12:49:45 +0200
|
|
Harald Hoyer |
f97365 |
Subject: [PATCH] Bring back 51-dracut-rescue-postinst.sh
|
|
Harald Hoyer |
f97365 |
|
|
Harald Hoyer |
f97365 |
can only be obsoleted after F30
|
|
Harald Hoyer |
f97365 |
---
|
|
Harald Hoyer |
f97365 |
51-dracut-rescue-postinst.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++
|
|
Harald Hoyer |
f97365 |
dracut.spec | 6 ++++
|
|
Harald Hoyer |
f97365 |
2 files changed, 74 insertions(+)
|
|
Harald Hoyer |
f97365 |
|
|
Harald Hoyer |
f97365 |
diff --git a/51-dracut-rescue-postinst.sh b/51-dracut-rescue-postinst.sh
|
|
Harald Hoyer |
f97365 |
new file mode 100755
|
|
Harald Hoyer |
f97365 |
index 00000000..67f5b717
|
|
Harald Hoyer |
f97365 |
--- /dev/null
|
|
Harald Hoyer |
f97365 |
+++ b/51-dracut-rescue-postinst.sh
|
|
Harald Hoyer |
f97365 |
@@ -0,0 +1,68 @@
|
|
Harald Hoyer |
f97365 |
+#!/bin/bash
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+export LANG=C
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+KERNEL_VERSION="$1"
|
|
Harald Hoyer |
f97365 |
+KERNEL_IMAGE="$2"
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+[[ -f /etc/os-release ]] && . /etc/os-release
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
|
|
Harald Hoyer |
f97365 |
+ systemd-machine-id-setup
|
|
Harald Hoyer |
f97365 |
+fi
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+[[ $MACHINE_ID ]] || exit 1
|
|
Harald Hoyer |
f97365 |
+[[ -f $KERNEL_IMAGE ]] || exit 1
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
|
|
Harald Hoyer |
f97365 |
+NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+dropindirs_sort()
|
|
Harald Hoyer |
f97365 |
+{
|
|
Harald Hoyer |
f97365 |
+ suffix=$1; shift
|
|
Harald Hoyer |
f97365 |
+ args=("$@")
|
|
Harald Hoyer |
f97365 |
+ files=$(
|
|
Harald Hoyer |
f97365 |
+ while (( $# > 0 )); do
|
|
Harald Hoyer |
f97365 |
+ for i in ${1}/*${suffix}; do
|
|
Harald Hoyer |
f97365 |
+ [[ -f $i ]] && echo ${i##*/}
|
|
Harald Hoyer |
f97365 |
+ done
|
|
Harald Hoyer |
f97365 |
+ shift
|
|
Harald Hoyer |
f97365 |
+ done | sort -Vu
|
|
Harald Hoyer |
f97365 |
+ )
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+ for f in $files; do
|
|
Harald Hoyer |
f97365 |
+ for d in "${args[@]}"; do
|
|
Harald Hoyer |
f97365 |
+ if [[ -f "$d/$f" ]]; then
|
|
Harald Hoyer |
f97365 |
+ echo "$d/$f"
|
|
Harald Hoyer |
f97365 |
+ continue 2
|
|
Harald Hoyer |
f97365 |
+ fi
|
|
Harald Hoyer |
f97365 |
+ done
|
|
Harald Hoyer |
f97365 |
+ done
|
|
Harald Hoyer |
f97365 |
+}
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+# source our config dir
|
|
Harald Hoyer |
f97365 |
+for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
|
|
Harald Hoyer |
f97365 |
+ [[ -e $f ]] && . "$f"
|
|
Harald Hoyer |
f97365 |
+done
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+[[ $dracut_rescue_image != "yes" ]] && exit 0
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+if [[ ! -f $INITRDFILE ]]; then
|
|
Harald Hoyer |
f97365 |
+ dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
|
|
Harald Hoyer |
f97365 |
+ ((ret+=$?))
|
|
Harald Hoyer |
f97365 |
+fi
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
|
|
Harald Hoyer |
f97365 |
+ cp --reflink=auto "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
|
|
Harald Hoyer |
f97365 |
+ ((ret+=$?))
|
|
Harald Hoyer |
f97365 |
+fi
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+((ret+=$?))
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+exit $ret
|
|
Harald Hoyer |
f97365 |
diff --git a/dracut.spec b/dracut.spec
|
|
Harald Hoyer |
f97365 |
index c218b63d..10cd7839 100644
|
|
Harald Hoyer |
f97365 |
--- a/dracut.spec
|
|
Harald Hoyer |
f97365 |
+++ b/dracut.spec
|
|
Harald Hoyer |
f97365 |
@@ -259,6 +259,10 @@ rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
|
|
Harald Hoyer |
f97365 |
%if 0%{?fedora} || 0%{?rhel}
|
|
Harald Hoyer |
f97365 |
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
|
|
Harald Hoyer |
f97365 |
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
|
|
Harald Hoyer |
f97365 |
+
|
|
Harald Hoyer |
f97365 |
+# FIXME: remove after F30
|
|
Harald Hoyer |
f97365 |
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
|
|
Harald Hoyer |
f97365 |
+install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
|
|
Harald Hoyer |
f97365 |
%endif
|
|
Harald Hoyer |
f97365 |
|
|
Harald Hoyer |
f97365 |
%files
|
|
Harald Hoyer |
f97365 |
@@ -452,6 +456,8 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
|
|
Harald Hoyer |
f97365 |
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
|
|
Harald Hoyer |
f97365 |
%if 0%{?fedora} || 0%{?rhel}
|
|
Harald Hoyer |
f97365 |
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
|
|
Harald Hoyer |
f97365 |
+# FIXME: remove after F30
|
|
Harald Hoyer |
f97365 |
+%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
|
|
Harald Hoyer |
f97365 |
%endif
|
|
Harald Hoyer |
f97365 |
|
|
Harald Hoyer |
f97365 |
%changelog
|
|
Harald Hoyer |
f97365 |
|