3 # Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
5 # You can use these to enable/disable modules without blacklisting them
7 # Make sure our imporant paths are included
8 PATH=$PATH:/usr/sbin:/sbin
10 # Appended to module file at the end when we want to ignore one
11 IGNORE_SUFFIX=".ignore"
14 # If 'module' is found, its renamed to 'module.ignore'
15 function module_disable {
16 # Basic check to see if this is a module available for loading
17 MODULE_CHECK=`modprobe -l $1`
18 if [ -z $MODULE_CHECK ]; then
19 echo "Module $1 not detected -- this is fine"
23 MODULE_KO=${MODULE}.ko
24 # In case there are more than one of these modules. This can
25 # happen, for example if your distribution provides one and you have
26 # compiled one in yourself later.
27 MODULE_COUNT=`find /lib/modules/$VER/ -name $MODULE_KO | wc -l`
28 ALL_MODULES=`find /lib/modules/$VER/ -name $MODULE_KO`
30 CHECK=`modprobe -l $MODULE`
31 for i in $ALL_MODULES; do
32 if [[ $MODULE_COUNT -gt 1 ]]; then
33 if [[ $COUNT -eq 1 ]]; then
34 echo -en "$MODULE_COUNT $MODULE modules found "
35 echo -e "we'll disable all of them"
37 echo -en "Disabling $MODULE ($COUNT) ..."
39 echo -en "Disabling $MODULE ..."
41 mv -f $i ${i}${IGNORE_SUFFIX}
43 CHECK_AGAIN=`modprobe -l $MODULE`
44 if [ "$CHECK" != "$CHECK_AGAIN" ]; then
45 echo -e "\t[OK]\tModule disabled:"
48 echo -e "[ERROR]\tModule is still being detected:"
55 # If 'module.ignore' is found, rename it back to 'module'
56 function module_enable {
58 MODULE_KO=${MODULE}.ko
59 IGNORED_MODULE=${MODULE_KO}${IGNORE_SUFFIX}
60 # In case there are more than one of these modules. This can
61 # happen, for example if your distribution provides one and you have
62 # compiled one in yourself later.
63 ALL_MODULES=`find /lib/modules/$VER/ -name $IGNORED_MODULE`
64 for i in $ALL_MODULES; do
65 echo -en "Enabling $MODULE ..."
69 CHECK=`modprobe -l $MODULE`
70 if [ "$DIR/$MODULE_KO" != $CHECK ]; then
71 if [ -z $CHECK ]; then
72 echo -e "\t[ERROR]\tModule could not be enabled"
74 echo -en "\t[OK]\tModule renamed but another "
75 echo "module file is being preferred"
76 echo -e "Renamed module:\t\t$DIR/$MODULE_KO"
77 echo -e "Preferred module:\t$CHECK"
80 echo -e "\t[OK]\tModule enabled: "
81 echo "$DIR/$MODULE_KO"
83 # Lets only do this for the first module found