This repository was archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuzlabina.sh
More file actions
executable file
·52 lines (49 loc) · 1.38 KB
/
uzlabina.sh
File metadata and controls
executable file
·52 lines (49 loc) · 1.38 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
#!/bin/bash
#Uzlabina Login
OKFORMAT="[\e[32mOK\e[0m ]"
WARNINGFORMAT="[\e[38;5;196mWARNING\e[0m]"
ERRORFORMAT="[\e[33mERROR\e[0m]"
if [[ $1 != "" ]]
then
if [[ $2 != "" ]]
then
username=$1
password=$2
fi
else
username=217
password=217
printf "No credentials specified, using defaults.\nUsage (optional): \e[38;5;44muzlabina.sh (username) (password) [timeout, default 10s]\e[0m\n"
fi
if [[ $3 != "" ]]
then
timeout=$3
else
timeout=10
fi
if nmcli | grep "spse.uzlabina.cz" > /dev/null
then
if
curl https://wifi.uzlabina.cz/ --silent > /dev/null
then
status=$(curl -X POST -F username=$username -F password=$password https://wifi.uzlabina.cz --silent --connect-timeout $timeout)
if echo "$status" | grep "Neplatné jméno nebo heslo" > /dev/null
then
echo -e "$ERRORFORMAT Invalid username/password"
elif echo "$status" | grep "IP adresa je již povolena" > /dev/null
then
echo -e "$OKFORMAT You were already logged in"
else
echo -e "$OKFORMAT \e[32mYou were successfully logged in\e[0m"
fi
else
echo -e "$ERRORFORMAT Úžlabina login is not available\nPlease try again later"
fi
else
if nmcli | grep "uzlabina" > /dev/null
then
echo -e "$WARNINGFORMAT \e[31mYou are not connected to a legitimate Úžlabina network!\nBe careful, your data may be compromised\e[0m"
else
echo -e "$ERRORFORMAT You are not connected to the Úžlabina WiFi network."
fi
fi