Skip to content

Commit cc87205

Browse files
committed
Split tunnel stuff into a separate script
1 parent c8652a5 commit cc87205

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

push.sh

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,6 @@ go build
4040

4141
wait
4242

43-
cf app $appname > /dev/null # Make sure app is there
44-
45-
if ! cf app $appname | grep -q running; then
46-
echo "ERROR: $appname is not running"
47-
exit 1
48-
fi
49-
50-
url=`cf app $appname | grep urls: | cut -d ' ' -f2`
51-
52-
# If there's an existing client running, kill it
53-
client_pids=`ps auxww | grep ./chisel | grep 5022:2022 | grep -v grep | awk '{print $2}'`
54-
if [ -n "$client_pids" ]; then
55-
kill $client_pids
56-
fi
57-
58-
./chisel client --keepalive 10s https://$url 5022:2022 > /dev/null &
59-
60-
cat <<_EOF_
61-
You can now connect via
62-
63-
ssh vcap@localhost -p 5022
64-
65-
or if you added an entry to ~/.ssh/config:
66-
67-
ssh chisel
68-
69-
_EOF_
43+
./tunnel
7044

7145
# vi: expandtab sw=2 ts=2

tunnel

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
set -e # exit on error
4+
5+
cd `dirname $0`
6+
7+
appname="cf-ssh-chisel-$USER"
8+
9+
echo "Checking if $appname is running"
10+
cf app $appname > /dev/null # Make sure app is there
11+
12+
if ! cf app $appname | grep -q running; then
13+
echo "ERROR: $appname is not running"
14+
exit 1
15+
fi
16+
17+
echo "Obtaining url for $appname"
18+
url=`cf app $appname | grep urls: | cut -d ' ' -f2`
19+
20+
# If there's an existing client running, kill it
21+
client_pids=`ps auxww | grep ./chisel | grep 5022:2022 | grep -v grep | awk '{print $2}'`
22+
if [ -n "$client_pids" ]; then
23+
kill $client_pids
24+
fi
25+
26+
echo "Starting client, connecting to $url"
27+
./chisel client --keepalive 10s https://$url 5022:2022 > /dev/null &
28+
29+
cat <<_EOF_
30+
You can now connect via
31+
32+
ssh vcap@localhost -p 5022
33+
34+
or if you added an entry to ~/.ssh/config:
35+
36+
ssh chisel
37+
38+
_EOF_
39+
40+
# vi: expandtab sw=2 ts=2

0 commit comments

Comments
 (0)