5 #@Created: 2011-01-22-15:20
7 PATH
=/bin
:/usr
/bin
:/usr
/local
/bin
17 echo "Usage: $PROGRAM [--list] [--all|-a] [--athome|-m] [--proxy|-x] [--help] [--version] [host-name]"
18 echo -e "for example:"
19 echo -e "\tmt.sh --list"
20 echo -e "\tmt.sh qapc29"
21 echo -e "\tmt.sh -x 192.168.79.xx tu98"
22 echo -e "\tmt.sh x103-22"
33 echo "$PROGRAM version $VERSION"
39 EXITCODE
=$
((EXITCODE
+ 1))
40 #EXITCODE=`expr $EXITCODE + 1`
47 HOMEPROXY
=192.168.1.105
48 SECONDPROXY
=192.168.72.103
55 if [[ $hostname = "football12" ]]
86 error
"Unrecognized option: $1"
95 #----------- end of phrase argument ---------------#
97 # make tunnel from local to destination by ssh server
102 # $5 record string for sed
106 echo "connect from local port $1 to $4 for $2:$3 ..."
107 ssh -N -f -L *:$1:$2:$3 $4
109 pid
=`ps -ef|grep ssh$|tail -1|awk '{print $2}'`
110 echo -e "\t$2:$3 $pid"
111 if grep -q $5 $HOME/tunnel.list
113 echo -e "\tyes, $5 in tunnel.list"
114 sed -e "s/$5.*$/$5 $pid/g" $HOME/tunnel.list
-i
116 echo "\tno, $5 not in tunnel.list, add it"
117 echo $5 $pid >> $HOME/tunnel.list
122 # make tunnel from local to destination by ssh server
123 # $1:local port $2:remote host name $3:remote port
126 if [ $athome = "yes" ]
128 echo "nothing for $2:$3 now"
129 #mt $1 $SECONDPROXY $1 $HOMEPROXY "$2:$3"
131 mt
$1 $2 $3 $QAPROXY "$2:$3"
138 cat $HOME/tunnel.list |
while read line
140 if ps
-ef|
grep `echo $line|cut -d " " -f2` |
grep -q ssh
144 echo $line |cut
-d " " -f1
149 if [ $option = "list" ]
155 if [ $# -eq 0 -a $all != "yes" ]
163 echo "use all setting, means connet to qasox02, qapc29 and others ..."
164 tunnel
="qasox02 qapc29 others"
166 echo "connet to $* ..."
174 maketunnel
10002 "qasox02.grid.datasynapse.com" 22
177 maketunnel
10006 "qasox06.grid.datasynapse.com" 22
180 maketunnel
10051 "qa51.grid.datasynapse.com" 22
183 maketunnel
9942 "qapc42.grid.datasynapse.com" 3389
186 maketunnel
9242 "qapc42.grid.datasynapse.com" 22
189 maketunnel
9945 "qapc45.grid.datasynapse.com" 3389
192 maketunnel
9929 "qapc29.grid.datasynapse.com" 3389
195 maketunnel
9229 "qapc29.grid.datasynapse.com" 22
198 maketunnel
9959 "qapc59.grid.datasynapse.com" 3389
201 mt
20058 "192.168.1.58" 3389 $THIRDPROXY "192.168.1.58:3389"
204 mt
22058 "192.168.1.58" 22 $THIRDPROXY "192.168.1.58:22"
207 mt
20098 "192.168.1.98" 3389 $THIRDPROXY "192.168.1.98:3389"
210 mt
22098 "192.168.1.98" 443 $THIRDPROXY "192.168.1.98:443"
213 mt
30103 "192.168.72.103" 3389 $HOMEPROXY "192.168.72.103:3389"
216 mt
32103 "192.168.72.103" 22 $HOMEPROXY "192.168.72.103:22"
219 if [ $athome = "yes" ]
221 mt
30195 192.168.67.195 3389 $HOMEPROXY "192.168.67.195:3389"
222 mt
32195 192.168.67.195 22 $HOMEPROXY "192.168.67.195:22"
224 maketunnel
9965 "qapc65.grid.datasynapse.com" 3389
225 maketunnel
9968 "qapc68.grid.datasynapse.com" 3389
226 maketunnel
9973 "qapc73.grid.datasynapse.com" 3389