-
Notifications
You must be signed in to change notification settings - Fork 4
/
which_vpn.sh
executable file
·43 lines (37 loc) · 1.03 KB
/
which_vpn.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
#!/usr/bin/env bash
# trying to find out which VPN you are connected to??
set -euo pipefail
if [[ "$HOSTNAME" == "biowulf.nih.gov" ]]
then
echo "DO NOT RUN THIS ON BIOWULF HEADNODE! This is script is meant for your laptop."
exit 1
elif [[ "$HOSTNAME" == "helix.nih.gov" ]]
then
echo "DO NOT RUN THIS ON HELIX! This script is meant for your laptop."
exit 1
elif [[ "$HOSTNAME" =~ cn[0-9]{4}$ ]]
then
echo "DO NOT RUN THIS ON a BIOWULF interactive node! This script is meant for your laptop"
exit 1
fi
# get ip
ip=$(ifconfig -a|grep "inet 10."|awk '{print $2}')
if [[ "$ip" == "" ]]
then
echo "Are you really connected to VPN?? Doesn't look like it!"
exit 1
fi
echo "Your VPN IP is $ip"
numbertwo=$(echo $ip|awk -F"." '{print $2}')
if [[ "$numbertwo" == "247" || "$numbertwo" == "248" ]]
then
echo "You are connected to the FREDERICK VPN!"
exit 0
elif [[ "$numbertwo" == "242" || "$numbertwo" == "243" ]]
then
echo "You are connected to the BETHESDA VPN!"
exit 0
else
echo "Sorry, I cannot guess which VPN you are connect to!"
exit 0
fi