diff --git a/defaults/initrd.d/00-modules.sh b/defaults/initrd.d/00-modules.sh new file mode 100755 index 0000000..dfe9f77 --- /dev/null +++ b/defaults/initrd.d/00-modules.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +. /etc/initrd.d/00-common.sh +. /etc/initrd.d/00-devmgr.sh + + +_modules_load() { + for module in ${*}; do + echo ${module} >> /etc/modules/extra_load + done + _modules_scan extra_load +} + +_modules_scan() { + local mods + local loaded + + mods=$(cat /etc/modules/${1} 2>/dev/null) + [ -n "${mods}" ] && [ -z "${QUIET}" ] && \ + echo -ne "${BOLD} ::${NORMAL} Loading from ${1}: " + + for x in ${mods}; do + local mload=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/") + if [ "${mload}" = "${x}" ]; then + # Only module to no-load + [ -z "${QUIET}" ] && \ + echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." + elif [ "${mload}" = "${MLIST}" ]; then + if [ -n "${DEBUG}" ]; then + echo -ne "${BOLD} ::${NORMAL} " + echo -ne "Scanning for ${x}..." + fi + modprobe ${x} > /dev/null 2>&1 + loaded=${?} + + [ -n "${DEBUG}" -a "${loaded}" = "0" ] && \ + echo "loaded" + [ -n "${DEBUG}" -a "${loaded}" != "0" ] && \ + echo "not loaded" + + [ -z "${DEBUG}" -a "${loaded}" = "0" ] && \ + [ -z "${QUIET}" ] && \ + echo -en "${x} " + else + [ -z "${QUIET}" ] && \ + echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." + fi + done + [ -n "${mods}" ] && [ -z "${QUIET}" ] && echo +} + +modules_init() { + if [ -z "${DO_modules}" ]; then + good_msg 'Skipping module load; disabled via commandline' + elif [ -d "/lib/modules/${KV}" ]; then + good_msg 'Loading modules' + # Load appropriate kernel modules + if [ "${NODETECT}" != "1" ]; then + for modules in ${MY_HWOPTS}; do + _modules_scan ${modules} + done + fi + # Always eval doload=... + _modules_load ${MDOLIST} + else + good_msg 'Skipping module load; no modules in the ramdisk!' + fi + + # Give udev time to execute all the rules. This may be beneficial + # for usb-storage devices. + is_udev && udevadm settle +} + diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index abc99e5..5f9165e 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -6,80 +6,9 @@ . /etc/initrd.d/00-fsdev.sh . /etc/initrd.d/00-devmgr.sh . /etc/initrd.d/00-zfs.sh +. /etc/initrd.d/00-modules.sh -modules_load() { - for module in $* - do - echo ${module} >> /etc/modules/extra_load - done - - modules_scan extra_load -} - -modules_scan() { - local MODS - local loaded - - MODS=$(cat /etc/modules/${1} 2>/dev/null) - [ -n "${MODS}" ] && [ -z "${QUIET}" ] && \ - echo -ne "${BOLD} ::${NORMAL} Loading from ${1}: " - - for x in ${MODS} - do - MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/") - if [ "${MLOAD}" = "${x}" ] # Only module to no-load - then - [ -z "${QUIET}" ] && \ - echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." - elif [ "${MLOAD}" = "${MLIST}" ] - then - if [ -n "${DEBUG}" ]; then - echo -ne "${BOLD} ::${NORMAL} " - echo -ne "Scanning for ${x}..." - fi - modprobe ${x} > /dev/null 2>&1 - loaded=${?} - - [ -n "${DEBUG}" -a "${loaded}" = "0" ] && \ - echo "loaded" - [ -n "${DEBUG}" -a "${loaded}" != "0" ] && \ - echo "not loaded" - - [ -z "${DEBUG}" -a "${loaded}" = "0" ] && \ - [ -z "${QUIET}" ] && \ - echo -en "${x} " - else - [ -z "${QUIET}" ] && \ - echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." - fi - done - [ -n "${MODS}" ] && [ -z "${QUIET}" ] && echo -} - -modules_init() { - if [ -z "${DO_modules}" ]; then - good_msg 'Skipping module load; disabled via commandline' - elif [ -d "/lib/modules/${KV}" ]; then - good_msg 'Loading modules' - # Load appropriate kernel modules - if [ "${NODETECT}" != '1' ]; then - for modules in ${MY_HWOPTS} - do - modules_scan ${modules} - done - fi - # Always eval doload=... - modules_load ${MDOLIST} - else - good_msg 'Skipping module load; no modules in the ramdisk!' - fi - - # Give udev time to execute all the rules. This may be beneficial - # for usb-storage devices. - is_udev && udevadm settle -} - uppercase() { # needs tr on busybox echo ${1} | tr 'a-z' 'A-Z' @@ -553,22 +482,6 @@ cmdline_hwopts() { MY_HWOPTS=${TMP_HWOPTS} } -load_modules() { - # Load modules listed in MY_HWOPTS if /lib/modules exists for the running - # kernel version - if [ -d "/lib/modules/${KV}" ] - then - good_msg 'Loading modules' - # Load appropriate kernel modules - for modules in $MY_HWOPTS - do - modules_scan $modules - done - else - good_msg 'Skipping module load; no modules in the ramdisk!' - fi -} - setup_keymap() { if [ "${DO_keymap}" ] then