forked from evanugarte/rpi-led-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtun.sh
44 lines (31 loc) · 887 Bytes
/
tun.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
#!/bin/bash
CORE_V4_IP=$(cat /app/config/config.json | jq -r ".CORE_V4_IP")
DOCKER_CONTAINER_KNOWN_HOSTS=/app/ssh/known_hosts
DOCKER_CONTAINER_SSH_KEYS=/app/ssh/id_rsa
CORE_V4_PORT=11000
LEDSIGN_PORT=80
CORE_V4_HOST=sce@${CORE_V4_IP}
open_ssh_tunnel () {
ssh -v \
-o UserKnownHostsFile=${DOCKER_CONTAINER_KNOWN_HOSTS} \
-o StrictHostKeyChecking=no \
-i ${DOCKER_CONTAINER_SSH_KEYS} \
-f -g -N -R 0.0.0.0:${CORE_V4_PORT}:localhost:${LEDSIGN_PORT} ${CORE_V4_HOST}
}
ls /app
ls /app/ssh
chmod 600 ${DOCKER_CONTAINER_SSH_KEYS}
open_ssh_tunnel
# if no value is sent along with the invocation of the script,
# run the server. otherwise just open the ssh tunnel. i.e.
#
# to open the tunnel and start the server:
# $ ./tun.sh
#
# to only open the tunnel:
# $ ./tun.sh tunnel-only
if [ -z "$1" ]
then
python /app/alerting.py
python /app/server.py
fi