-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·103 lines (88 loc) · 1.52 KB
/
main.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
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
#!/bin/bash
DnsCheck()
{
#Based on the windows DNS check as long windows detects that the dns is working this works too.
if [[ $(dig +short dns.msftncsi.com) = "131.107.255.255" ]]; then
echo "DNS Up";
return 0;
else
echo "DNS Down"
return 1;
fi
}
InternetCheck()
{
#Google never goes down so this will work for a long time.
if curl -s google.com > /dev/null ; then
echo "Internet available";
return 0;
else
echo "Internet not available";
return 1;
fi
}
OnlineCheck()
{
if ! DnsCheck ; then
sleep 30; #Wait 30sec and try again
if ! DnsCheck ; then
echo "turn off because DNS seems to be not available.";
exit;
fi
fi
if ! InternetCheck ; then
sleep 30; #Wait 30sec and try
if ! InternetCheck ; then
echo "Internet Connection Lost";
exit;
fi
fi
}
IP_BEFORE=""
FirewallCheck()
{
if DnsCheck ; then
echo "ERROR: Firewall does not block DNS";
exit;
fi
if InternetCheck ; then
echo "ERROR: Firwall does not block internet";
exit;
fi
}
IpCheck()
{
NEW_IP=$( curl -s ifconfig.me )
if [ "$IP_BEFORE" = "$NEW_IP" ]; then
echo "ERROR: IP is the same!! INITIATE SHUTDOWN";
exit;
else
echo "VPN has masked the IP";
fi
}
Init()
{
OnlineCheck;
IP_BEFORE=$( curl -s ifconfig.me );
echo "Normal IP is: "$IP_BEFORE;
./OpenVPNconfig.sh;
./Firewall.sh;
FirewallCheck;
cd /etc/openvpn;
openvpn openvpn.conf &
sleep 30;
cd /home;
OnlineCheck;
IpCheck;
/init & #start the JDownloader
sleep 30;
}
Loop()
{
IpCheck;
OnlineCheck;
sleep 5m;
Loop;
}
Init;
Loop;