#
# DESCRIPTION:
#
#   load all modules which are necessary to access the boot media
#
# part of the LiveBackup project:  
#
#                     http://livebackup.sourceforge.net/
#
# Copyright 2006-2010 by Wolfgang Rohrmoser <info@rohrmoser-engineering.de>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

msg -i -n "loading essential kernel modules "

if [ "$DISCOVER" ] && [ "$(which discover)" ]; then

    m1=$(cat /etc/modules.essential | grep -v ^#)
    m2=$(discover --data-path=linux/module/name --data-path=linux/module/options --format="%s %s" | sort | uniq)
    modules="$m1 $m2"

elif [ -f /etc/modules ]; then

    modules=$(cat /etc/modules | grep -v ^#)
    
else

    modules=""
    for name in $(ls -1 /lib/modules/$kversion/*.ko); do
        modules="$modules $(basename $name .ko)"
    done
    
fi


for module in $modules; do
    inc_progress_bar

    if [ $LB_DEBUG -gt 50 ]; then
        msg -i -e -n "\n$module : "
        modprobe -v $module 
    else
        modprobe $module > /dev/null 2>&1
        if [ $? -eq 0 ]; then 
	    msg -i -n "."
        else	
	    msg -i -n "-"
        fi
    fi
done

msg -i " done"


#
# Local Variables: 
# mode: shell-script
# End: 
#
