network:dhcp:wait_for_ipv6_dad() in PREINIT6
[dracut.git] / 50-dracut.install
blobd05abb9a577922ddffac5740bda8fa63c2b5a729
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
23 elif [[ -f /usr/lib/kernel/cmdline ]]; then
24 readarray -t BOOT_OPTIONS < /usr/lib/kernel/cmdline
27 if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
28 read -ar BOOT_OPTIONS < /proc/cmdline
31 unset noimageifnotneeded
33 for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
34 if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
35 noimageifnotneeded="yes"
36 break
38 done
39 dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
40 ret=$?
42 remove)
43 rm -f -- "$BOOT_DIR_ABS"/initrd
44 ret=$?
46 esac
47 exit $ret