File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 5
5
id_rsa.pub
6
6
ssh_host_rsa_key
7
7
ssh_host_rsa_key.pub
8
+
9
+ # Ignore any pid files
10
+ tunnel- * .pid
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ cd `dirname $0`
6
6
7
7
appname=" cf-ssh-chisel-$USER "
8
8
echo " Starting $appname forwarding local port ${CHISEL_LOCAL_PORT:= 5022} to remote port ${CHISEL_REMOTE_PORT:= 2022} "
9
+ pidfile=tunnel-${CHISEL_LOCAL_PORT} .pid
9
10
10
11
echo " Checking if $appname is running"
11
12
cf app $appname > /dev/null # Make sure app is there
@@ -23,6 +24,11 @@ url=`cf app $appname | egrep 'routes|urls' | awk '{print $2}'`
23
24
echo " $url " | grep " $appname " | grep -q predix.io || { echo " URL doesn't look sane: $url " ; exit 2; }
24
25
25
26
# If there's an existing client running, kill it
27
+ if [ -r " $pidfile " ]; then
28
+ kill $( cat " $pidfile " ) 2> /dev/null
29
+ rm " $pidfile "
30
+ fi
31
+
26
32
client_pids=` ps auxww | grep ./chisel | grep ${CHISEL_LOCAL_PORT} :${CHISEL_REMOTE_PORT} | grep -v grep | awk ' {print $2}' `
27
33
if [ -n " $client_pids " ]; then
28
34
kill $client_pids
@@ -32,6 +38,7 @@ echo "Starting client, connecting to $url"
32
38
cmd=" ./chisel client --keepalive 10s https://$url ${CHISEL_LOCAL_PORT} :${CHISEL_REMOTE_PORT} "
33
39
echo " Running in background: $cmd "
34
40
$cmd > /dev/null &
41
+ echo $# > " $pidfile "
35
42
36
43
cat << _EOF_
37
44
You can now connect via
You can’t perform that action at this time.
0 commit comments