#! /bin/sh

#
# This script can be started inside initrd with busybox. 
# No modules get actually loaded, the script writes is a list of 
# discovered modules to stdout. These modules can be modprobed later if 
# filesystems are mounted and kernel-module tree is available.
# 

modules=$(discover --data-path=linux/module/name --data-path=linux/module/options --format="%s %s" | sort | uniq)

for mod in $modules; do

    name=$(echo $mod | sed 's/^\([^ ]\+\).*/\1/')

    if [ $name = "ignore" ] || [ $name = "unknown" ]; then
        continue
    fi

    echo "$mod "

done

exit 0

