# kmod - load modules from /etc/modules
#
# This task loads the kernel modules specified in the /etc/modules file

description	"load modules from /etc/modules"

start on (startup
	  and started udev)

task
script
    [ -f /etc/modules ] && files="/etc/modules" || files=""
    hash="#"
    dirs="/etc/modules-load.d /run/modules-load.d /lib/modules-load.d"
    for dir in $dirs; do
        files="$files $(run-parts --list --regex='\.conf$' $dir 2> /dev/null || true)"
    done
    for file in $files; do
        while read module args; do
	    [ -n "$module" ] && [ "${module#${hash}}" = "${module}" ] || continue
	    modprobe $module $args || :
        done < $file
    done
end script
