-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution.sh
executable file
·56 lines (45 loc) · 1.16 KB
/
solution.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
statuscheck()
{
if [ $1 -ne 0 ]
then
echo $2
echo "Exiting...."
exit 0
fi
}
CURR=$(cd "$(dirname "$0")" ; pwd -P )
echo $CURR
echo -n "Enter the sudo password : "
read -s password
cmd=$(echo $password | sudo -S lshw -C network -short 2>/dev/null | grep Wireless | awk '{print $2 " " $4}')
if sudo -n true ; then
echo "I got the sudo password"
else
echo "Wrong sudo password"
echo "Either replace the password in this script or give password via command line arguments"
echo "Exiting...."
exit 0
fi
#the return value is a single string having a space
#splitting by space and storing in a array
cmd=($cmd)
echo "Wifi Interface: "${cmd[0]}
echo "Wifi Driver: "${cmd[1]}
if [ -d "rtlwifi_new" ]
then
rm -rf rtlwifi_new
fi
git clone https://github.com/kindlerprince/rtlwifi_new.git
statuscheck $? "Failed to cloned Repository"
cd rtlwifi_new
make
statuscheck $? "Error occured in make"
sudo make install
statuscheck $? "Error occured in make"
sudo modprobe -rv ${cmd[1]}
sudo modprobe -v ${cmd[1]} ant_sel=2
sudo ip link set ${cmd[0]} up
sudo iw dev ${cmd[0]} scan
make clean
echo "Wifi Driver Installed Successfully"