# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
-if [[ -f /etc/kernel/cmdline ]]; then
- readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
-fi
+COMMAND="$1"
+KERNEL_VERSION="$2"
+BOOT_DIR_ABS="$3"
+KERNEL_IMAGE="$4"
-if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
- readarray -t BOOT_OPTIONS < /proc/cmdline
-fi
+ret=0
+case "$COMMAND" in
+ add)
+ if [[ -f /etc/kernel/cmdline ]]; then
+ readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
+ fi
-unset noimageifnotneeded
+ if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
+ read -ar BOOT_OPTIONS < /proc/cmdline
+ fi
-for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
- if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
- noimageifnotneeded="yes"
- break
- fi
-done
+ unset noimageifnotneeded
-ret=0
-case "$1" in
- add)
- dracut ${noimageifnotneeded:+--noimageifnotneeded} "$3"/initrd "$2"
+ for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
+ if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
+ noimageifnotneeded="yes"
+ break
+ fi
+ done
+ dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
ret=$?
;;
remove)
- rm -f -- "$3"/initrd
+ rm -f -- "$BOOT_DIR_ABS"/initrd
ret=$?
;;
esac