-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWifiConnect2.0.sh
75 lines (60 loc) · 1.99 KB
/
WifiConnect2.0.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
clear
printf "Enter your network card name [ex. wlan0]: "
read NwCard
printf "\n"
while true
do
printf "$(tput setaf 2)Welcome to Wifi Connecter\n"
printf "$(tput setaf 1)author: Michał Wieczorek$(tput setaf 2)\n\n"
printf "connect - Connect you to a network\n"
printf "netinfo - Shows you current net connection\n"
printf "exit - Exit\n\n"
read komenda
if [ "$komenda" == "connect" ]; then
clear
printf "$(tput setaf 1)Disconnecting from current wifi & restarting network services..."
service network-manager restart
service networking restart
ifconfig $NwCard down
printf "\n\nStarting up $NwCard...\n"
ifconfig $NwCard up
printf "$(tput setaf 1)Scanning available networks...\n\n"
printf "$(tput setaf 2)Networks:\n$(tput setaf 7)"
iw $NwCard scan | grep "SSID"
printf "\n\nSet the name of a network you want to connect: "
read SSID
printf "\nSet a password: "
read -s PASSWORD
printf "\n\n$(tput setaf 1)Creating password file for $SSID"
wpa_passphrase $SSID $PASSWORD >> password.conf
printf "\n\n$(tput setaf 2)Connecting to: $SSID\n\n$(tput setaf 7)"
rm -rf /run/wpa_supplicant/$NwCard
killall wpa_supplicant
wpa_supplicant -B -i $NwCard -c password.conf -D wext -C /run/wpa_supplicant GROUP=wheel
printf "\n$(tput setaf 1)Deleting password.conf\n"
rm password.conf
printf "\nGetting ip\n"
dhclient -r $NwCard
dhclient $NwCard
printf "$(tput setaf 2)\nYou are now connected to:$(tput setaf 7)\n"
iw $NwCard link | grep -e "SSID" -e "Not"
printf "\n$(tput setaf 2)Connection info:$(tput setaf 7)\n"
ifconfig $NwCard | grep "inet"
printf "\n\n"
continue
elif [ "$komenda" == "netinfo" ]; then
clear
printf "$(tput setaf 2)You are now connected to:$(tput setaf 7)\n"
iw $NwCard link | grep -e "SSID" -e "Not"
printf "\n$(tput setaf 2)Connection info:$(tput setaf 7)\n"
ifconfig $NwCard | grep "inet"
printf "\n\n"
continue
elif [ "$komenda" == "exit" ]; then
exit
else
clear
continue
fi
done