#!/bin/sh -e

for i in /boot/vmlinu[xz]*; do
	version="${i##*/vmlinu[xz]}"
	# Support filenames with no version. LILO supports this, but GRUB
	# doesn't (currently).
	version="${version#-}"
	if ! [ -d /lib/modules/"$version" ]; then
		printf '>>> %s: no modules installed, skipping\n' "$version" >&2
		continue
	fi
	printf '>>> %s\n' "$version" >&2
	dracut --force --quiet /boot/initramfs-"$version".img "$version"
done