]> git.ipfire.org Git - thirdparty/dracut.git/blame - 50-dracut.install
95fcoe: add timeout initqueue entries
[thirdparty/dracut.git] / 50-dracut.install
CommitLineData
69395a52 1#!/bin/bash
9dd9d81f 2
ccb8ce04
HH
3COMMAND="$1"
4KERNEL_VERSION="$2"
5BOOT_DIR_ABS="$3"
6KERNEL_IMAGE="$4"
83bb0893 7
b71d162a
YW
8# If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory.
9# So, let's skip to create initrd.
10if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
11 exit 0
12fi
13
ccb8ce04
HH
14ret=0
15case "$COMMAND" in
16 add)
bc140a0b
HH
17 INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd
18 if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then
19 # we found an initrd at the same place as the kernel
20 # use this and don't generate a new one
8cd88205 21 cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/initrd" \
bc140a0b
HH
22 && chown root:root "$BOOT_DIR_ABS/initrd" \
23 && chmod 0600 "$BOOT_DIR_ABS/initrd" \
24 && exit 0
25 fi
26
ccb8ce04 27 if [[ -f /etc/kernel/cmdline ]]; then
a6018700 28 read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
a7d3ad67 29 elif [[ -f /usr/lib/kernel/cmdline ]]; then
a6018700 30 read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
ccb8ce04 31 fi
83bb0893 32
a6018700
HH
33 if ! [[ ${BOOT_OPTIONS[*]} ]]; then
34 read -r -d '' -a BOOT_OPTIONS < /proc/cmdline
ccb8ce04 35 fi
83bb0893 36
ccb8ce04 37 unset noimageifnotneeded
83bb0893 38
ccb8ce04
HH
39 for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
40 if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
41 noimageifnotneeded="yes"
42 break
43 fi
44 done
45 dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
9dd9d81f
HH
46 ret=$?
47 ;;
48 remove)
ccb8ce04 49 rm -f -- "$BOOT_DIR_ABS"/initrd
9dd9d81f
HH
50 ret=$?
51 ;;
52esac
53exit $ret