-
Notifications
You must be signed in to change notification settings - Fork 11
/
run_mt.sh
58 lines (46 loc) · 1.4 KB
/
run_mt.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# Break script on any non-zero status of any command
set -e
export DISPLAY SCREEN_NUM SCREEN_WHD
XVFB_PID=0
TERMINAL_PID=0
term_handler() {
echo '########################################'
echo 'SIGTERM signal received'
if ps -p $TERMINAL_PID > /dev/null; then
kill -SIGTERM $TERMINAL_PID
# Wait returns status of the killed process, with set -e this breaks the script
wait $TERMINAL_PID || true
fi
# Wait end of all wine processes
/docker/waitonprocess.sh wineserver
if ps -p $XVFB_PID > /dev/null; then
kill -SIGTERM $XVFB_PID
# Wait returns status of the killed process, with set -e this breaks the script
wait $XVFB_PID || true
fi
# SIGTERM comes from docker stop so treat it as normal signal
exit 0
}
trap 'term_handler' SIGTERM
Xvfb $DISPLAY -screen $SCREEN_NUM $SCREEN_WHD \
+extension GLX \
+extension RANDR \
+extension RENDER \
&> /tmp/xvfb.log &
XVFB_PID=$!
sleep 2
echo “lanzando VNC y fluxbox”
# VNC
fluxbox & x11vnc -bg -rfbport 5900 -forever -xkb -o /tmp/x11vnc.log -passwd 3579
sleep 2
echo “lanzando MetaTrader”
# @TODO Use special argument to pass value "startup.ini"
wine terminal /portable startup.ini &
TERMINAL_PID=$!
# Wait end of terminal
wait $TERMINAL_PID
# Wait end of all wine processes
/docker/waitonprocess.sh wineserver
# Wait end of Xvfb
wait $XVFB_PID