#!/bin/bash

. /lib/dracut-lib.sh

if ! getargbool 1 kgraft; then
	info "[kGraft] Disabled on kernel commandline, not loading any patches"
	exit 0
fi

modules=($(find "/lib/modules/$(uname -r)/kgraft" -name 'kgraft[-_]patch*.ko' \
		-printf '%P\n'))
if test ${#modules[@]} -eq 0; then
	info "[kGraft] No patches found"
	exit 0
fi
err=0
for mod in "${modules[@]}"; do
	mod=${mod%.ko}
	info "[kGraft] Loading $mod"
	modprobe "${mod##*/}" || err=$?
done
exit $err
