#!/bin/bash

type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh

if getargbool 1 klp; then
	modules=($(find "/lib/modules/$(uname -r)/livepatch" -type f | \
			sed -rn 's:.*/(livepatch[^/]*)\.ko(\.[gx]z|\.zst)?$:\1:p'))

	if test ${#modules[@]} -gt 0; then
		for mod in "${modules[@]}"; do
			info "[klp] Loading $mod"
			modprobe "${mod##*/}"
		done
	else
		info "[klp] No patches found"
	fi
else
	info "[klp] Disabled on kernel commandline, not loading any patches"
fi

