| 1 |
#!/bin/sh |
| 2 |
# uninstall-modules |
| 3 |
# |
| 4 |
# Remove all the modules passed in on the command line from the modules |
| 5 |
# directory. This script is called by the makefile. |
| 6 |
|
| 7 |
KERNEL_MODULES_DIR=$1 |
| 8 |
shift |
| 9 |
MODULES="$*" |
| 10 |
|
| 11 |
usage() { |
| 12 |
echo "$0: Used to delete kernel modules from the modules directory." |
| 13 |
echo "" |
| 14 |
echo "Usage:" |
| 15 |
echo " $0 MODULES_BASE_DIR mod1 [mod2 [...]]" |
| 16 |
echo "" |
| 17 |
echo " MODULES_BASE_DIR - typically /lib/modules/KVERS" |
| 18 |
echo " modN - (optionally partial) module name to remove." |
| 19 |
} |
| 20 |
|
| 21 |
if [ -z "$KERNEL_MODULES_DIR" ]; then |
| 22 |
echo "Missing kernel module directory." |
| 23 |
usage |
| 24 |
exit 1; |
| 25 |
fi |
| 26 |
|
| 27 |
if [ -z "$MODULES" ]; then |
| 28 |
echo "Missing one or more modules to delete." |
| 29 |
usage |
| 30 |
exit 1; |
| 31 |
fi |
| 32 |
for mod in $MODULES; do |
| 33 |
BASE=`basename $mod` |
| 34 |
for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep "$BASE$"`; do |
| 35 |
if [ -e "$file" ]; then |
| 36 |
#echo "Deleting $file." |
| 37 |
rm -f $file |
| 38 |
fi |
| 39 |
done |
| 40 |
done |
| 41 |
exit 0 |