3 : ${PATTERN='\(ath_.*\|wlan_.*\|wlan\)$'}
6 test "$(id -u)" = 0 || {
7 echo "ERROR: You must be root to run this script" >&2
11 test -r /proc/modules || {
12 echo "ERROR: Cannot read /proc/modules" >&2
17 while test "$tries" != "0"; do
21 for line in $(cat /proc/modules); do
29 expr "$name" : "$PATTERN" >/dev/null || continue
31 # Compatibility for Linux 2.4.x
32 test -z "$state" && { use_name="-"; state="Live"; }
34 if test "$state" != "Live" || test "$use_count" != "0" || \
35 test "$use_name" != "-"; then
36 # Don't skip unload in the last run
37 if test "$tries" != "1"; then
43 echo "Unloading \"$name\""
45 /sbin/rmmod "$name" || {
46 echo "ERROR: cannot unload module \"$name\"" >&2
49 sync # to be even safer
51 test "$skipped" = "0" && break