@@ -13,25 +13,32 @@ die () {
1313 exit $errnum
1414}
1515
16+ if [ -f /var/run/secrets/kubernetes.io/serviceaccount/token ]; then
17+ log " Kubernetes service account found."
18+ export USE_KUBERNETES=true
19+ fi
20+
1621# ==============================================
1722# Java blocks until kernel have enough entropy
1823# to generate the /dev/random seed
1924# ==============================================
2025# See: SeleniumHQ/docker-selenium/issues/14
21- sudo haveged
26+ # Added a non-sudo conditional so this works on non-sudo environments like K8s
27+ (sudo haveged) || haveged
2228
2329# Workaround that might help to get dbus working in docker
2430# http://stackoverflow.com/a/38355729/511069
2531# https://github.com/SeleniumHQ/docker-selenium/issues/87#issuecomment-187659234
2632# - still unclear if this helps: `-v /var/run/dbus:/var/run/dbus`
2733# - this works generates errors: DBUS_SESSION_BUS_ADDRESS="/dev/null"
2834# - this gives less erros: DBUS_SESSION_BUS_ADDRESS="unix:abstract=/dev/null"
29- sudo rm -f /var/lib/dbus/machine-id
30- sudo mkdir -p /var/run/dbus
31- sudo service dbus restart > dbus_service.log
35+ # Added a non-sudo conditional so this works on non-sudo environments like K8s
36+ (sudo rm -f /var/lib/dbus/machine-id) || (rm -f /var/lib/dbus/machine-id) || true
37+ (sudo mkdir -p /var/run/dbus) || (mkdir -p /var/run/dbus) || true
38+ (sudo service dbus restart > dbus_service.log) || (service dbus restart > dbus_service.log) || true
3239# Test dbus works
33- service dbus status > dbus_service_status.log
34- export $( dbus-launch)
40+ ( service dbus status > dbus_service_status.log) || true
41+ export $( dbus-launch) || true
3542export NSS_USE_SHARED_DB=ENABLED
3643# echo "-- INFO: DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
3744# => e.g. DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-APZO4BE4TJ,guid=6e9c098d053d3038cb0756ae57ecc885
@@ -44,22 +51,11 @@ stop >/dev/null 2>&1 || true
4451rm -f ${LOGS_DIR} /*
4552rm -f ${RUN_DIR} /*
4653
47- # Support restart docker container for selenium 3 @aituganov
48- if [ ! -f /usr/bin/geckodriver ]; then
49- sudo mv /opt/geckodriver /usr/bin/geckodriver
50- sudo ln -fs /usr/bin/geckodriver /opt/geckodriver
51- fi
52-
53- sudo cp /capabilities3.json /capabilities.json
54- sudo cp /capabilities3.json /home/seluser/capabilities.json
55- sudo cp /capabilities3.json /home/seluser/caps.json
56-
5754# ---------------------
5855# Fix/extend ENV vars
5956# ---------------------
6057export SELENIUM_JAR_PATH=" /home/seluser/selenium-server-standalone-3.jar"
6158export FIREFOX_DEST_BIN=" /home/seluser/firefox-for-sel-3/firefox"
62- sudo ln -fs ${FIREFOX_DEST_BIN} /usr/bin/firefox
6359export DOSEL_VERSION=$( cat VERSION)
6460export FIREFOX_VERSION=$( firefox_version)
6561# CHROME_FLAVOR would allow to have separate installations for stable, beta, unstable
@@ -183,7 +179,7 @@ echo "Please send us a PR if you know how to set the path for the Firefox browse
183179# When running for Zalenium prepare certain customizations
184180if [ " ${ZALENIUM} " == " true" ]; then
185181 # Set proper desktop background
186- sudo mv -f /usr/share/images/fluxbox/wallpaper-zalenium.png /usr/share/images/fluxbox/ubuntu-light.png
182+ mv -f /usr/share/images/fluxbox/wallpaper-zalenium.png /usr/share/images/fluxbox/ubuntu-light.png
187183fi
188184
189185# TODO: Remove this duplicated logic
@@ -375,24 +371,23 @@ ga_track_start () {
375371 fi
376372}
377373
378- # ----------------------------------------
379- # Remove lock files, thanks @garagepoort
380- # clear_x_locks.sh
381-
382374# --------------------------------
383375# Improve etc/hosts and fix dirs
384- improve_etc_hosts.sh
385- fix_dirs.sh
376+ if [ " ${USE_KUBERNETES} " == " false" ]; then
377+ sudo improve_etc_hosts.sh
378+ fi
386379
387380# -------------------------
388381# Docker alongside docker
389- docker_alongside_docker.sh
382+ if [ " ${USE_KUBERNETES} " == " false" ]; then
383+ docker_alongside_docker.sh
384+ fi
390385
391386# -------------------------------
392387# Fix small tiny 64mb shm issue
393388# -------------------------------
394389# https://github.com/elgalu/docker-selenium/issues/20
395- if [ " ${SHM_TRY_MOUNT_UNMOUNT} " = " true" ]; then
390+ if [ " ${SHM_TRY_MOUNT_UNMOUNT} " = " true" ] && [ " ${USE_KUBERNETES} " == " false " ] ; then
396391 sudo umount /dev/shm || true
397392 sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=${SHM_SIZE} \
398393 tmpfs /dev/shm || true
@@ -440,6 +435,7 @@ echo "${SEL_UNREGISTER_IF_STILL_DOWN_AFTER}" > SEL_UNREGISTER_IF_STILL_DOWN_AFTE
440435echo " ${SELENIUM_NODE_PARAMS} " > SELENIUM_NODE_PARAMS
441436echo " ${CUSTOM_SELENIUM_NODE_PROXY_PARAMS} " > CUSTOM_SELENIUM_NODE_PROXY_PARAMS
442437echo " ${CUSTOM_SELENIUM_NODE_REGISTER_CYCLE} " > CUSTOM_SELENIUM_NODE_REGISTER_CYCLE
438+ echo " ${USE_KUBERNETES} " > USE_KUBERNETES
443439echo " ${XMANAGER} " > XMANAGER
444440echo " ${GRID} " > GRID
445441
0 commit comments