2 # Copyright 2006 Kel Modderman <kelrin@tpg.com.au>
4 # Taken from madwifi scripts. This unloads madwifi
6 : ${PATTERN='\(ath_.*\|wlan_.*\|wlan\)$'}
9 test "`id -u`" = 0 || {
10 echo "ERROR: You must be root to run this script" >&2
14 test -r /proc/modules || {
15 echo "ERROR: Cannot read /proc/modules" >&2
20 while test "$tries" != "0"; do
24 for line in `cat /proc/modules`; do
32 expr "$name" : "$PATTERN" >/dev/null || continue
34 # Compatibility for Linux 2.4.x
35 test -z "$state" && { use_name="-"; state="Live"; }
37 if test "$state" != "Live" || test "$use_count" != "0" || \
38 test "$use_name" != "-"; then
39 # Don't skip unload in the last run
40 if test "$tries" != "1"; then
46 echo "Unloading \"$name\""
48 /sbin/rmmod "$name" || {
49 echo "ERROR: cannot unload module \"$name\"" >&2
52 sync # to be even safer
54 test "$skipped" = "0" && break