-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-chrome-gui.sh
executable file
·57 lines (47 loc) · 1.38 KB
/
run-chrome-gui.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
#!/bin/bash
DEBUG_PORT=$1
VNC_PORT=$2
DISPLAY=$3
if [ -z $DEBUG_PORT ]; then
echo "Debug port must be passed as first positional argument (e.g. 9222)"
exit 1;
fi;
if [ -z $VNC_PORT ]; then
echo "VNC port must be passed as second positional argument (e.g. 5900)"
exit 1;
fi;
if [ -z $DISPLAY ]; then
echo "Display var must be passed as third positional argument (e.g. :99)"
exit 1;
fi;
# Check if DISPLAY is already in use to avoid multiple vnc servers on a single display (that would be bad)
xvfbProcessCount=$(ps -ef | grep -c "Xvfb $DISPLAY")
if [ "$xvfbProcessCount" -ge 2 ]; then
echo "There is already an Xvfb process running on display $DISPLAY. Choose a different value for the display positional argument."
exit 1;
fi;
containerId=$(docker run \
--rm \
--detach \
-it \
-e DEBUG_PORT=$DEBUG_PORT \
-e VNC_PORT=$VNC_PORT \
-e DISPLAY=$DISPLAY \
--network=host \
chrome-gui-hyperaccs)
if [ -z $containerId ]; then
echo "Could not get containerId";
exit 1;
fi;
# Wait for 200 status from json/version
until curl -I -s http://localhost:$DEBUG_PORT/json/version | grep -q '200 OK'
do
sleep 0.5
done;
# Get the websocket debugger URL
wsEndpoint=$(curl -s http://localhost:$DEBUG_PORT/json/version | jq -r '.webSocketDebuggerUrl')
if [ -z $wsEndpoint ]; then
echo "Could not get wsEndpoint";
exit 1;
fi;
echo "{\"containerId\":\"$containerId\",\"wsEndpoint\":\"$wsEndpoint\"}"