forked from manhinhang/ib-gateway-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.sh
executable file
·40 lines (32 loc) · 893 Bytes
/
cmd.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
#!/bin/bash
set -e
# set -x
echo "Starting Xvfb..."
rm -f /tmp/.X0-lock
/usr/bin/Xvfb "${DISPLAY}" -ac -screen 0 1024x768x16 +extension RANDR &
echo "Waiting for Xvfb to be ready..."
while ! xdpyinfo -display "${DISPLAY}"; do
echo -n '.'
sleep 0.1
done
echo "Xvfb is ready"
if [ -n "${VNC_SERVER_PASSWORD}" ]; then
echo "Starting VNC server"
x11vnc -ncache_cr -display "${DISPLAY}" -forever -shared -logappend /var/log/x11vnc.log -bg -noipv6 -passwd "${VNC_SERVER_PASSWORD}"
fi
echo "Setup port forwarding..."
socat TCP-LISTEN:4002,fork TCP:localhost:4001,forever 1>>/var/log/socat.log 2>&1 &
echo "*****************************"
python /root/bootstrap.py
echo "IB gateway is ready."
#Define cleanup procedure
cleanup() {
pkill java
pkill x11vnc
pkill Xvfb
pkill socat
echo "Container stopped, performing cleanup..."
}
#Trap TERM
trap 'cleanup' INT TERM
$@