]> git.ipfire.org Git - thirdparty/dracut.git/blame - 50-dracut.install
mdraid: wait for rd.md.uuid specified devices to be assembled
[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
ccb8ce04
HH
8ret=0
9case "$COMMAND" in
10 add)
bc140a0b
HH
11 INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd
12 if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then
13 # we found an initrd at the same place as the kernel
14 # use this and don't generate a new one
8cd88205 15 cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/initrd" \
bc140a0b
HH
16 && chown root:root "$BOOT_DIR_ABS/initrd" \
17 && chmod 0600 "$BOOT_DIR_ABS/initrd" \
18 && exit 0
19 fi
20
ccb8ce04 21 if [[ -f /etc/kernel/cmdline ]]; then
a6018700 22 read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
a7d3ad67 23 elif [[ -f /usr/lib/kernel/cmdline ]]; then
a6018700 24 read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
ccb8ce04 25 fi
83bb0893 26
a6018700
HH
27 if ! [[ ${BOOT_OPTIONS[*]} ]]; then
28 read -r -d '' -a BOOT_OPTIONS < /proc/cmdline
ccb8ce04 29 fi
83bb0893 30
ccb8ce04 31 unset noimageifnotneeded
83bb0893 32
ccb8ce04
HH
33 for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
34 if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
35 noimageifnotneeded="yes"
36 break
37 fi
38 done
39 dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
9dd9d81f
HH
40 ret=$?
41 ;;
42 remove)
ccb8ce04 43 rm -f -- "$BOOT_DIR_ABS"/initrd
9dd9d81f
HH
44 ret=$?
45 ;;
46esac
47exit $ret