-
Notifications
You must be signed in to change notification settings - Fork 4
/
entry_point.sh
executable file
·68 lines (54 loc) · 1.79 KB
/
entry_point.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
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
source /opt/bin/functions.sh
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
if [ ! -e /opt/selenium/config.json ]; then
echo No Selenium Node configuration file, the node-base image is not intended to be run directly. 1>&2
exit 1
fi
if [ -z "$HUB_PORT_4444_TCP_ADDR" ]; then
echo Not linked with a running Hub container 1>&2
exit 1
fi
function shutdown {
kill -s SIGTERM $NODE_PID
wait $NODE_PID
}
REMOTE_HOST_PARAM=""
if [ ! -z "$REMOTE_HOST" ]; then
echo "REMOTE_HOST variable is set, appending -remoteHost"
REMOTE_HOST_PARAM="-remoteHost $REMOTE_HOST"
fi
if [ ! -z "$SE_OPTS" ]; then
echo "appending selenium options: ${SE_OPTS}"
fi
# TODO: Look into http://www.seleniumhq.org/docs/05_selenium_rc.jsp#browser-side-logs
SERVERNUM=$(get_server_num)
env | cut -f 1 -d "=" | sort > asroot
sudo -E -u seluser -i env | cut -f 1 -d "=" | sort > asseluser
# Add root environment variables that are not present in the seluser
# environment to an environment file.
$(for E in $(grep -vxFf asseluser asroot); do echo $E="'${!E}'" >> ~seluser/selenv; done) \
echo "DISPLAY=${DISPLAY}" >> ~seluser/selenv
sudo -E -i -u seluser \
source selenv && \
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
-role node \
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \
${REMOTE_HOST_PARAM} \
-nodeConfig /opt/selenium/config.json \
${SE_OPTS} &
NODE_PID=$!
trap shutdown SIGTERM SIGINT
for i in $(seq 1 10)
do
xdpyinfo -display $DISPLAY >/dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi
echo Waiting xvfb...
sleep 0.5
done
fluxbox -display $DISPLAY &
x11vnc -forever -shared -rfbport 5900 -display $DISPLAY &
wait $NODE_PID