network/net-lib.sh:parse_iscsi_root(): fix c&p bug
[dracut.git] / 50-dracut.install
blob5ac74f1f4d5c6f08016dca0da388cca19c0262e5
1 #!/bin/sh
3 COMMAND="$1"
4 KERNEL_VERSION="$2"
5 BOOT_DIR_ABS="$3"
6 KERNEL_IMAGE="$4"
8 ret=0
9 case "$COMMAND" in
10 add)
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
15 cp "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/initrd" \
16 && chown root:root "$BOOT_DIR_ABS/initrd" \
17 && chmod 0600 "$BOOT_DIR_ABS/initrd" \
18 && exit 0
21 if [[ -f /etc/kernel/cmdline ]]; then
22 readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
25 if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
26 read -ar BOOT_OPTIONS < /proc/cmdline
29 unset noimageifnotneeded
31 for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
32 if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
33 noimageifnotneeded="yes"
34 break
36 done
37 dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
38 ret=$?
40 remove)
41 rm -f -- "$BOOT_DIR_ABS"/initrd
42 ret=$?
44 esac
45 exit $ret