-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path407wpa.sh
More file actions
executable file
·33 lines (33 loc) · 821 Bytes
/
407wpa.sh
File metadata and controls
executable file
·33 lines (33 loc) · 821 Bytes
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
#!/bin/bash
#use this script to set wpa wireless connect
pass="";
essid="";
tmpfile=$(date +%F);
function prog_stat()
{
if [ "$(pidof $1)" != "" ];then
echo ON;
else
echo OFF;
fi
}
function usage()
{
echo "Usage: $(basename $1) -s essid -p password"
exit 3;
}
echo configuration file generating...
essid="407" pass="15829311229"
( [ "$essid" == "" ] || [ "$pass" == "" ] ) && usage $0
wpa_passphrase $essid $pass > /tmp/$tmpfile;
if [ "$(prog_stat wpa_supplicant)" == "ON" ];then
echo wpa_supplicant is on,please check!
echo "kill wpa_supplicant ..."
killall wpa_supplicant
fi
echo "wpa connecting...."
sudo wpa_supplicant -B -iwlan0 -c /tmp/$tmpfile -Dnl80211
echo "config wlan0"
#dhclient -cf /etc/dhcp/dhclient.conf wlan0
ifconfig wlan0 192.168.0.13 netmask 255.255.255.0
route add default gw 192.168.0.1