| 1 | #
 | 
  
    | 2 | #	     THIS IS FREE SOFTWARE 
 | 
  
    | 3 | #
 | 
  
    | 4 | # Copyright 2016 Filippo "Fil" Bergamo
 | 
  
    | 5 | # 
 | 
  
    | 6 | # Licensed under the Apache License, Version 2.0 (the "License");
 | 
  
    | 7 | # you may not use this file except in compliance with the License.
 | 
  
    | 8 | # You may obtain a copy of the License at
 | 
  
    | 9 | # 
 | 
  
    | 10 | #     http://www.apache.org/licenses/LICENSE-2.0
 | 
  
    | 11 | # 
 | 
  
    | 12 | # Unless required by applicable law or agreed to in writing, software
 | 
  
    | 13 | # distributed under the License is distributed on an "AS IS" BASIS,
 | 
  
    | 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
  
    | 15 | # See the License for the specific language governing permissions and
 | 
  
    | 16 | # limitations under the License.
 | 
  
    | 17 | 
 | 
  
    | 18 | 
 | 
  
    | 19 | globresult=0
 | 
  
    | 20 | 
 | 
  
    | 21 | # check, for every module, if it is running,
 | 
  
    | 22 | # if not, insmod it.
 | 
  
    | 23 | 
 | 
  
    | 24 | 
 | 
  
    | 25 | # ---- mac80211 ----
 | 
  
    | 26 | mod=$(ls /sys/module | grep -c -Fx "mac80211")
 | 
  
    | 27 | if [ $mod = "0" ]; then
 | 
  
    | 28 | 	echo -n -e "\tloading module mac80211.ko ..."
 | 
  
    | 29 | 	insmod /system/lib/modules/mac80211.ko
 | 
  
    | 30 | 	if [ $? = 0 ]; then
 | 
  
    | 31 | 		echo " [ OK! ]"
 | 
  
    | 32 | 	else
 | 
  
    | 33 | 		globresult=-1
 | 
  
    | 34 | 		echo " [* FAIL! *]"
 | 
  
    | 35 | 	fi
 | 
  
    | 36 | else
 | 
  
    | 37 | 	echo -e "\tmac80211.ko already loaded [ OK! ]"
 | 
  
    | 38 | fi
 | 
  
    | 39 | 
 | 
  
    | 40 | 
 | 
  
    | 41 | 
 | 
  
    | 42 | # ---- ath.ko ----
 | 
  
    | 43 | mod=$(ls /sys/module | grep -c -Fx "ath")
 | 
  
    | 44 | if [ $mod = "0" ]; then
 | 
  
    | 45 | 	echo -n -e "\tloading module ath.ko ..."
 | 
  
    | 46 | 	insmod /system/lib/modules/ath.ko
 | 
  
    | 47 | 	if [ $? = 0 ]; then
 | 
  
    | 48 | 		echo " [ OK! ]"
 | 
  
    | 49 | 	else
 | 
  
    | 50 | 		globresult=-1
 | 
  
    | 51 | 		echo " [* FAIL! *]"
 | 
  
    | 52 | 	fi
 | 
  
    | 53 | else
 | 
  
    | 54 | 	echo -e "\tath.ko already loaded [ OK! ]"
 | 
  
    | 55 | fi
 | 
  
    | 56 | 
 | 
  
    | 57 | 
 | 
  
    | 58 | 
 | 
  
    | 59 | # ---- ath9k_hw ----
 | 
  
    | 60 | mod=$(ls /sys/module | grep -c -Fx "ath9k_hw")
 | 
  
    | 61 | if [ $mod = "0" ]; then
 | 
  
    | 62 | 	echo -n -e "\tloading module ath9k_hw.ko ..."
 | 
  
    | 63 | 	insmod /system/lib/modules/ath9k_hw.ko
 | 
  
    | 64 | 	if [ $? = 0 ]; then
 | 
  
    | 65 | 		echo " [ OK! ]"
 | 
  
    | 66 | 	else
 | 
  
    | 67 | 		globresult=-1
 | 
  
    | 68 | 		echo " [* FAIL! *]"
 | 
  
    | 69 | 	fi
 | 
  
    | 70 | else
 | 
  
    | 71 | 	echo -e "\tath9k_hw.ko already loaded [ OK! ]"
 | 
  
    | 72 | fi
 | 
  
    | 73 | 
 | 
  
    | 74 | 
 | 
  
    | 75 | 
 | 
  
    | 76 | # ---- ath9k_common ----
 | 
  
    | 77 | mod=$(ls /sys/module | grep -c -Fx "ath9k_common")
 | 
  
    | 78 | if [ $mod = "0" ]; then
 | 
  
    | 79 | 	echo -n -e "\tloading module ath9k_common.ko ..."
 | 
  
    | 80 | 	insmod /system/lib/modules/ath9k_common.ko
 | 
  
    | 81 | 	if [ $? = 0 ]; then
 | 
  
    | 82 | 		echo " [ OK! ]"
 | 
  
    | 83 | 	else
 | 
  
    | 84 | 		globresult=-1
 | 
  
    | 85 | 		echo " [* FAIL! *]"
 | 
  
    | 86 | 	fi
 | 
  
    | 87 | else
 | 
  
    | 88 | 	echo -e "\tath9k_common.ko already loaded [ OK! ]"
 | 
  
    | 89 | fi
 | 
  
    | 90 | 
 | 
  
    | 91 | 
 | 
  
    | 92 | 
 | 
  
    | 93 | # ---- ath0k_htc ----
 | 
  
    | 94 | mod=$(ls /sys/module | grep -c -Fx "ath9k_htc")
 | 
  
    | 95 | if [ $mod = "0" ]; then
 | 
  
    | 96 | 	echo -n -e "\tloading module ath9k_htc.ko ..."
 | 
  
    | 97 | 	insmod /system/lib/modules/ath9k_htc.ko
 | 
  
    | 98 | 	if [ $? = 0 ]; then
 | 
  
    | 99 | 		echo " [ OK! ]"
 | 
  
    | 100 | 	else
 | 
  
    | 101 | 		globresult=-1
 | 
  
    | 102 | 		echo " [* FAIL! *]"
 | 
  
    | 103 | 	fi
 | 
  
    | 104 | else
 | 
  
    | 105 | 	echo -e "\tath9k_htc.ko already loaded [ OK! ]"
 | 
  
    | 106 | fi
 | 
  
    | 107 | 
 | 
  
    | 108 | 
 | 
  
    | 109 | 
 | 
  
    | 110 | # check for global result:
 | 
  
    | 111 | if [ $globresult -lt 0 ]; then
 | 
  
    | 112 | 	echo "ERRORS loading one or more modules.."
 | 
  
    | 113 | 	echo "Try re-running the script.."
 | 
  
    | 114 | else
 | 
  
    | 115 | 	echo "All modules loaded!"
 | 
  
    | 116 | fi
 |