From 1f227d62bf079e96771ee49ba499281da326f4e9 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 19 Aug 2008 15:25:06 +0000 Subject: Allow renaming of modules, #103 thanks to Sven. --- conf.d/modules | 4 ++++ init.d/modules.in | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/conf.d/modules b/conf.d/modules index 2fc26cf3..c5a3627c 100644 --- a/conf.d/modules +++ b/conf.d/modules @@ -5,6 +5,10 @@ #modules_2_6="tun" #modules="ohci1394" +# You can give modules a different name when they load - the new name +# will also be used to pick arguments below. +#modules="dummy:dummy1" + # Give the modules some arguments if needed, per version if necessary. #module_ieee1394_args="debug" #module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394" diff --git a/init.d/modules.in b/init.d/modules.in index da5550c1..06b5f179 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -23,7 +23,7 @@ start() x=${KV#*.*.} local KV_MICRO=${x%%-*} - local list= x= xx= y= args= cnt=0 + local list= x= xx= y= args= mpargs= cnt=0 a= for x in "${KV}" \ ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ ${KV_MAJOR}.${KV_MINOR} \ @@ -34,17 +34,29 @@ start() [ -z "${list}" ] && list=${modules} for x in ${list}; do - ebegin "Loading module ${x}" + a=${x#*:} + if [ "${a}" = "${x}" ]; then + unset mpargs + ebegin "Loading module ${x}" + else + x=${x%%:*} + mpargs="-o ${a}" + ebegin "Loading module ${x} as ${a}" + fi + aa=$(shell_var "${a}") xx=$(shell_var "${x}") for y in "${KV}" \ ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ ${KV_MAJOR}.${KV_MINOR} \ ; do + eval args=\$module_${aa}_args_$(shell_var "${y}") + [ -n "${args}" ] && break eval args=\$module_${xx}_args_$(shell_var "${y}") [ -n "${args}" ] && break done + [ -z "${args}" ] && eval args=\$module_${aa}_args [ -z "${args}" ] && eval args=\$module_${xx}_args - eval modprobe -q "${x}" "${args}" + eval modprobe -q "${mpargs}" "${x}" "${args}" eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1)) done einfo "Autoloaded ${cnt} module(s)" -- cgit v1.2.3