Last active
November 24, 2020 19:42
-
-
Save HarshitRuwali/b3e7f075964c259a0d7afbca452d8079 to your computer and use it in GitHub Desktop.
Check whether you have got a VPN activated or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Checking for VPN establishment | |
# TO DO: get your ip when not connected to a VPN, and replace the first 6 digits with the [a]bc[.][d]ef[.][g]hi[.] | |
# for ex if my ip is 123.456.789.000 format as [1]23[.][4]56[.] | |
# also change the name name of yor country. | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' | |
ip=$(curl ifconfig.me) | |
data=$(curl ifconfig.me/all) | |
con=$(curl ifconfig.co/country) | |
echo "$data" | |
if [ -z "$ip" ] | |
then | |
echo "No Internet Connection." | |
exit 1 | |
elif [[ "$ip" =~ [[a]bc[.][d]ef[.] ]] # TO change | |
then | |
echo "VPN not established, IP : $ip" | |
else | |
echo "VPN established, IP : $ip" | |
fi | |
if [[ "$con" == "" ]] # TO write your country name | |
then | |
echo "IP is ${RED}not bouncing${NC} of the country." | |
else | |
echo "VPN establishment ${GREEN}confirmed.${NC}" | |
echo "Country:${GREEN} $con ${NC}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment