-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpnlink-1.0.0-1.all.noarch.sh
executable file
·158 lines (141 loc) · 6.26 KB
/
vpnlink-1.0.0-1.all.noarch.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
################ Script Info ################
## Program: Link to my office network V1.0
## Author:Clumart.G
## Date: 2013-05-08
## Update:None
################ Env Define ################
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:~/sbin
LANG=C
export PATH
export LANG
################ Var Setting ################
InputVar=$*
HomeDir="/tmp/autoscript/"
################ Func Define ################
function _info_msg() {
_header
echo -e " | |"
echo -e " | Thank you for use vpnlink! |"
echo -e " | |"
echo -e " | Version: 1.0 |"
echo -e " | |"
echo -e " | http://www.idcsrv.com |"
echo -e " | |"
echo -e " | Author:翅儿学飞(Clumart.G) |"
echo -e " | Email:[email protected] |"
echo -e " | QQ:1810836851 |"
echo -e " | QQ群:61749648 |"
echo -e " | |"
echo -e " | Hit [ENTER] to continue or ctrl+c to exit |"
echo -e " | |"
printf " o----------------------------------------------------------------o\n"
read entcs
clear
}
function _end_msg() {
echo -e "###################################################################"
echo ""
echo -e " Configure Finish :)"
echo ""
echo -e "###################################################################"
echo ""
echo ""
_header
echo -e " | |"
echo -e " | Thank you for use vpnlink! |"
echo -e " | |"
echo -e " | The software is working! |"
echo -e " | |"
echo -e " | http://www.idcsrv.com |"
echo -e " | |"
echo -e " | Author:翅儿学飞(Clumart.G) |"
echo -e " | Email:[email protected] |"
echo -e " | QQ:1810836851 |"
echo -e " | QQ群:61749648 |"
echo -e " | |"
printf " o----------------------------------------------------------------o\n"
}
function _header() {
printf " o----------------------------------------------------------------o\n"
printf " | :: VPN LINK v1.0.0 (2013/05/08) |\n"
printf " o----------------------------------------------------------------o\n"
}
##Program Function
################ Main ################
clear
_info_msg
if [ `id -u` != "0" ]; then
echo -e "You need to be be the root user to run this script.\nWe also suggest you use a direct root login, not su -, sudo etc..."
exit 1
fi
if [ ! -d $HomeDir ]; then
mkdir -p $HomeDir
fi
cd $HomeDir || exit 1
read -p "Please choose your system:[mac|rpi]" -t 10 sys
sys=`echo $sys|tr A-Z a-z|tr -s " "`
if [ "${sys}x" == 'macx' ]; then
echo "I'm running on a mac system,only client function can be used!";
read -p "Route operate:[add|delete]" -t 10 routeop;
routeop=`echo $routeop|tr A-Z a-z|tr -s " "`
read -p "Default Config:[1(3G150B)|2(New)]" -t 10 config;
config=`echo ${config}|tr -s " "`
if [ "${config}x" == "1x" ]; then
gw="192.168.13.42";
else
read -p "Your VPN Server IP:" -t 10 gw;
gw=`echo ${gw}|tr -s " "`;
fi
if [ "${routeop}x" == "x" ] || [ "${gw}x" == "x" ];then
echo "I could't get your route operate or vpn server ip,i'm exit. Bye :(";
exit 0;
else
route ${routeop} -net 10.0.0.0/8 ${gw};
route ${routeop} -net 172.16.0.0/13 ${gw};
echo "============ route updated ============"
echo "============ run 'netstat -nr' to check! ============"
fi
elif [ "${sys}x" == "rpix" ];then
echo "I'm running a rpi system,i can be a route or a client :)"
if [ -z "`whereis openconnect |cut -d' ' -f2|grep '/'`" ]; then
echo "I need openconnect! I'm trying install it :)";
apt-get -y update
apt-get -y install openconnect
if [ -z "`whereis openconnect |cut -d' ' -f2|grep '/'`" ]; then
echo "I need openconnect,but i cann't install it :(";
exit 0;
fi
fi
read -p "Nat Src IP Config:[1(192.168.13.0/24)|2(New)]" -t 10 srcip;
srcip=`echo ${srcip}|tr -s " "`
if [ "${srcip}x" == "1x" ]; then
srcip="192.168.13.0/24";
else
read -p "Your SRC IP Range:" -t 60 srcip;
srcip=`echo ${srcip}|tr -s " "`;
fi
read -p "Choose ISP:[cnc|ct|auto]" -t 20 isp;
read -p "Username:" -t 60 usr;
read -s -p "Password:" -t 60 pwd;
isp=`echo $isp|tr A-Z a-z|tr -s " "`;
if [ "${isp}x" == "ctx" ];then
echo ${pwd}|openconnect -b --no-cert-check --authgroup=RSA_Token_Auth --user=${usr} --passwd-on-stdin ct-vpn.baidu.com
elif [ "${isp}x" == "cncx" ];then
echo ${pwd}|openconnect -b --no-cert-check --authgroup=RSA_Token_Auth --user=${usr} --passwd-on-stdin cnc-vpn.baidu.com
else
echo "I'll location by your local dns :)"
echo ${pwd}|openconnect -b --no-cert-check --authgroup=RSA_Token_Auth --user=${usr} --passwd-on-stdin vpn.baidu.com
fi
iptables -t nat -I POSTROUTING -s ${srcip} -o tun0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
clear
echo "============== vpn connected =============="
echo "=== run 'ifconfig' | 'route -n' | 'iptables' to check! ==="
else
echo "I can't get your system infomation,i'm exit. Bye :(";
exit 0;
fi
_end_msg
############ Clean Cache ############
rm -rf ${HomeDir}