-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwifi.sh
More file actions
executable file
·126 lines (96 loc) · 2.67 KB
/
wifi.sh
File metadata and controls
executable file
·126 lines (96 loc) · 2.67 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
############################################################
# This script will scan and Set WIFI #
# #
# VE3RD Created 2022/08/01 #
############################################################
#set -o errexit
#set -o pipefail
#set -e
sudo mount -o remount,rw / > /dev/null
trap ctrl_c INT
function ctrl_c() {
exit
}
export NCURSES_NO_UTF8_ACS=1
clear
echo -e "\e[1;97;44m"
tput setab 4
clear
##Set default colors
sudo sed -i '/use_colors = /c\use_colors = ON' ~/.dialogrc
sudo sed -i '/screen_color = /c\screen_color = (WHITE,BLUE,ON)' ~/.dialogrc
sudo sed -i '/title_color = /c\title_color = (YELLOW,RED,ON)' ~/.dialogrc
sudo sed -i '/tag_color = /c\tag_color = (YELLOW,BLUE,OFF)' ~/.dialogrc
sudo sed -i '/tag_key_color = /c\tag_key_color = (YELLOW,BLUE,OFF)' ~/.dialogrc
sudo sed -i '/tag_key_selected_color = /c\tag_key_selected_color = (YELLOW,BLUE,ON)' ~/.dialogrc
Mode="RO"
CallSign=""
DID=""
RED='\033[0;31m'
NC='\033[0m' # No Color
#printf "I ${RED}love${NC} Stack Overflow\n"
mode=$1
if [ -z "$mode" ]; then
mode="RO"
fi
function Home(){
ssid="TP-LINK_DB09"
pwd="Passport135"
# sudo nmcli dev wifi connect "TP-LINK_DB09" password "Password135"
sudo nmcli dev wifi connect "$ssid" password "$pwd"
return
}
function Phone(){
ssid="TP-LINK_DB09M"
pwd="Passport135"
# sudo nmcli dev wifi connect "TP-LINK_DB09M" password "Password135"
sudo nmcli dev wifi connect "$ssid" password "$pwd"
return
}
function SafetyCheck(){
dialog \
--stdout \
--ascii-lines \
--backtitle "Hotspot Configurator - by VE3RD" \
--clear \
--yesno "Do you want to Set your WiFi to $ssid" 7 50
exitcode=$?
if [ $exitcode == 0 ]; then
sudo nmcli dev wifi connect "$ssid" password "$pwd"
fi
}
######### Start of Functions ################
function ScanWiFi(){
options=$( iwlist wlan0 scan |grep -wv \x00 | grep ESSID | cut -d ":" -f2 | awk '{print $1, FNR, "N/A"}')
ssid=$(dialog \
--ascii-lines \
--backtitle "Hotspot Configurator - by VE3RD" \
--title "WiFi ESSID Selector" \
--stdout \
--radiolist "Select ESSID from the following List:" 22 90 16 \
"${cmd[@]}" ${options})
exitcode=$?
ssid=$(echo "$ssid" | tr -d '"')
if [ $exitcode -eq 0 ]; then
pwd=$(dialog \
--stdout \
--ascii-lines \
--inputbox "Enter your Password for $ssid" 20 30 )
dialog \
--stdout \
--ascii-lines \
--title "Selected ESID $ssid MODE = $Mode" \
--infobox "\nResults Ready to Set\n\nESSID = $ssid\nPassw = $pwd\n\n" 20 80
SafetyCheck
fi
}
if [ "$1" == "Home" ]; then
Home
exit
fi
if [ "$1" == "Phone" ]; then
Phone
exit
fi
ScanWiFi