-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·94 lines (78 loc) · 2.89 KB
/
entrypoint.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
VIDEO_RESOLUTION=${SCREEN_RESOLUTION:-"1920x1080"}
SCREEN_RESOLUTION=${SCREEN_RESOLUTION:-"${VIDEO_RESOLUTION}x24"}
DISPLAY_NUM=99
export DISPLAY=":$DISPLAY_NUM"
export DEFAULT_DATE=`date '+%Y%m%d%H%M%S'`
VERBOSE=${VERBOSE:-""}
DRIVER_ARGS=${DRIVER_ARGS:-""}
if [ -n "$VERBOSE" ]; then
DRIVER_ARGS="$DRIVER_ARGS --verbose"
fi
clean() {
if [ -n "$FFMPEG_PID" ]; then
kill "$FFMPEG_PID"
sleep 10
fi
if [ -n "$XSELD_PID" ]; then
kill -TERM "$XSELD_PID"
fi
if [ -n "$XVFB_PID" ]; then
kill -TERM "$XVFB_PID"
fi
if [ -n "$DRIVER_PID" ]; then
kill -TERM "$DRIVER_PID"
fi
if [ -n "$X11VNC_PID" ]; then
kill -TERM "$X11VNC_PID"
fi
if [ -n "$DEVTOOLS_PID" ]; then
kill -TERM "$DEVTOOLS_PID"
fi
}
trap clean SIGINT SIGTERM
if env | grep -q ROOT_CA_; then
mkdir -p $HOME/.pki/nssdb
certutil -N --empty-password -d sql:$HOME/.pki/nssdb
for e in $(env | grep ROOT_CA_ | sed -e 's/=.*$//'); do
certname=$(echo -n $e | sed -e 's/ROOT_CA_//')
echo ${!e} | base64 -d >/tmp/cert.pem
certutil -A -n ${certname} -t "TCu,Cu,Tu" -i /tmp/cert.pem -d sql:$HOME/.pki/nssdb
rm /tmp/cert.pem
done
fi
#/usr/bin/fileserver &
#FILESERVER_PID=$!
/usr/bin/devtools &
DEVTOOLS_PID=$!
/home/selenium/vncproxy --static /home/selenium/static &
VNCPROXY_PID=$1
DISPLAY="$DISPLAY" /usr/bin/xseld &
XSELD_PID=$!
while ip addr | grep inet | grep -q tentative > /dev/null; do sleep 0.1; done
mkdir -p ~/pulse/.config/pulse
echo -n 'gIvST5iz2S0J1+JlXC1lD3HWvg61vDTV1xbmiGxZnjB6E3psXsjWUVQS4SRrch6rygQgtpw7qmghDFTaekt8qWiCjGvB0LNzQbvhfs1SFYDMakmIXuoqYoWFqTJ+GOXYByxpgCMylMKwpOoANEDePUCj36nwGaJNTNSjL8WBv+Bf3rJXqWnJ/43a0hUhmBBt28Dhiz6Yqowa83Y4iDRNJbxih6rB1vRNDKqRr/J9XJV+dOlM0dI+K6Vf5Ag+2LGZ3rc5sPVqgHgKK0mcNcsn+yCmO+XLQHD1K+QgL8RITs7nNeF1ikYPVgEYnc0CGzHTMvFR7JLgwL2gTXulCdwPbg=='| base64 -d>~/pulse/.config/pulse/cookie
HOME=$HOME/pulse pulseaudio --start --exit-idle-time=-1
pulseaudio --start --exit-idle-time=-1
HOME=$HOME/pulse pactl load-module module-native-protocol-tcp
PULSE_PID=$(ps --no-headers -C pulseaudio -o pid | sed -r 's/( )+//g')
/usr/bin/xvfb-run -l -n "$DISPLAY_NUM" -s "-ac -screen 0 $SCREEN_RESOLUTION -noreset -listen tcp" /usr/bin/fluxbox -display "$DISPLAY" -log /dev/null 2>/dev/null &
XVFB_PID=$!
retcode=1
until [ $retcode -eq 0 ]; do
DISPLAY="$DISPLAY" wmctrl -m >/dev/null 2>&1
retcode=$?
if [ $retcode -ne 0 ]; then
echo Waiting X server...
sleep 0.1
fi
done
if [ "$ENABLE_VNC" == "true" ]; then
x11vnc -display "$DISPLAY" -passwd selenium -shared -forever -loop500 -rfbport 5900 -rfbportv6 5900 -logfile /dev/null &
X11VNC_PID=$!
fi
if [ "$ENABLE_VNC_AUDIO" == "true" ]; then
nohup ffmpeg -y -nostdin -f alsa -i pulse -f mpegts -codec:a mp2 udp://localhost:1234 > /home/selenium/Downloads/${DEFAULT_DATE}-vnc-audio.log 2>&1 &
fi
DISPLAY="$DISPLAY" google-chrome --start-maximized --no-sandbox --disable-dev-shm-usage --disable-gpu&
wait