File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change
1
+ CHISEL_LOCAL_PORT=${CHISEL_LOCAL_PORT:- 5022}
2
+ CHISEL_REMOTE_PORT=${CHISEL_REMOTE_PORT:- 2022}
Original file line number Diff line number Diff line change 3
3
set -e # exit on error
4
4
5
5
cd ` dirname $0 `
6
+ source .default.sh
6
7
7
8
appname=" cf-ssh-chisel-$USER "
8
9
9
10
# Generate a key to identify the server (if one doesn't already exist)
10
11
# TODO: put all generated files (this and id_rsa.pub) into a single directory
11
12
if [ ! -r ssh_host_rsa_key ]; then
12
13
ssh-keygen -t rsa -f ssh_host_rsa_key -N ' ' -C " chisel-ssh identity for $appname "
13
- echo ' [localhost]:5022 ' ` cat ssh_host_rsa_key.pub` >> ~ /.ssh/known_hosts
14
+ echo ' [localhost]:$CHISEL_LOCAL_PORT ' ` cat ssh_host_rsa_key.pub` >> ~ /.ssh/known_hosts
14
15
fi
15
16
16
17
if [ ! -r id_rsa.pub ]; then
@@ -27,7 +28,7 @@ have one.
27
28
Host chisel
28
29
ForwardAgent yes
29
30
HostName localhost
30
- Port 5022
31
+ Port $CHISEL_LOCAL_PORT
31
32
User vcap
32
33
Compression yes
33
34
_EOF_
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ set -e # exit on error
5
5
cd ` dirname $0 `
6
6
7
7
appname=" cf-ssh-chisel-$USER "
8
+ echo " Starting $appname forwarding local port ${CHISEL_LOCAL_PORT:= 5022} to remote port ${CHISEL_REMOTE_PORT:= 2022} "
8
9
9
10
echo " Checking if $appname is running"
10
11
cf app $appname > /dev/null # Make sure app is there
@@ -22,18 +23,20 @@ url=`cf app $appname | egrep 'routes|urls' | awk '{print $2}'`
22
23
echo " $url " | grep " $appname " | grep -q predix.io || { echo " URL doesn't look sane: $url " ; exit 2; }
23
24
24
25
# If there's an existing client running, kill it
25
- client_pids=` ps auxww | grep ./chisel | grep 5022:2022 | grep -v grep | awk ' {print $2}' `
26
+ client_pids=` ps auxww | grep ./chisel | grep ${CHISEL_LOCAL_PORT} : ${CHISEL_REMOTE_PORT} | grep -v grep | awk ' {print $2}' `
26
27
if [ -n " $client_pids " ]; then
27
28
kill $client_pids
28
29
fi
29
30
30
31
echo " Starting client, connecting to $url "
31
- ./chisel client --keepalive 10s https://$url 5022:2022 > /dev/null &
32
+ cmd=" ./chisel client --keepalive 10s https://$url ${CHISEL_LOCAL_PORT} :${CHISEL_REMOTE_PORT} "
33
+ echo " Running in background: $cmd "
34
+ $cmd > /dev/null &
32
35
33
36
cat << _EOF_
34
37
You can now connect via
35
38
36
- ssh vcap@localhost -p 5022
39
+ ssh vcap@localhost -p ${CHISEL_LOCAL_PORT}
37
40
38
41
or **IF** you added an entry to ~/.ssh/config:
39
42
You can’t perform that action at this time.
0 commit comments