@@ -172,9 +172,10 @@ echo "Setting --user-data-dir=/home/seluser/chrome-user-data-dir" > "${LOGS_DIR}
172172echo " breaks the ability of clients to set Chrome options via the capabilities." >> " ${LOGS_DIR} /chrome_browser.log"
173173echo " Please send us a PR if you know how to set the path for the Firefox browser logs." >> " ${LOGS_DIR} /chrome_browser.log"
174174# When running for Zalenium prepare certain customizations
175- # if [ "${ZALENIUM}" == "true" ]; then
176- # export CHROME_ADDITIONAL_ARGS="--user-data-dir=/home/seluser/chrome-user-data-dir"
177- # fi
175+ if [ " ${ZALENIUM} " == " true" ]; then
176+ # Set proper desktop background
177+ sudo mv -f /usr/share/images/fluxbox/wallpaper-zalenium.png /usr/share/images/fluxbox/ubuntu-light.png
178+ fi
178179
179180# TODO: Remove this duplicated logic
180181if [ " ${SELENIUM_HUB_PORT} " = " 0" ]; then
@@ -362,134 +363,9 @@ fix_dirs.sh
362363# Docker alongside docker
363364docker_alongside_docker.sh
364365
365- # ----------------------------------------
366- # Fix autoassigned ports
367- # ----------------------------------------
368366# Open a new file descriptor that redirects to stdout:
369367exec 3>&1
370368
371- function get_free_display() {
372- local selected_disp_num=" -1"
373- local find_display_num=-1
374-
375- # Get a list of socket DISPLAYs already used
376- netstat -nlp 2> /dev/null | grep -Po ' (?<=\/tmp\/\.X11-unix\/X)([0-9]+)' | sort -u > /tmp/netstatX11.log
377- # [ ! -s /tmp/netstatX11.log ] && echo "-- INFO: Emtpy file /tmp/netstatX11.log" 1>&3
378-
379- # important: while loops are executed in a subshell
380- # var assignments will be lost unless using <<<
381- # using 11.0 12.3 1.8 and so on didn't work, left as a reference
382- # local pythonCmd="from random import shuffle;list1 = list(range($MAX_DISPLAY_SEARCH));shuffle(list1);list2 = [x/10 for x in list1];str_res = ' '.join(str(e) for e in list2);print (str_res)"
383- local pythonCmd=" from random import shuffle;list1 = list(range($MAX_DISPLAY_SEARCH ));shuffle(list1);print (' '.join(str(e) for e in list1))"
384- local displayNums=$( python -c " ${pythonCmd} " )
385- # Always find a free DISPLAY port starting with current DISP_N if it was provided
386- [ " ${DISP_N} " != " -1" ] && displayNums=" ${DISP_N} ${displayNums} "
387- IFS=' ' read -r -a arrayDispNums <<< " $displayNums"
388- for find_display_num in ${arrayDispNums[@]} ; do
389- # read -r Do not treat a backslash character in any special way.
390- # Consider each backslash to be part of the input line.
391- # -s file is not zero size
392- if [ -s /tmp/netstatX11.log ]; then
393- while read read_disp_num ; do
394- if [ " ${read_disp_num} " = " ${find_display_num} " ]; then
395- echo " -- WARN: DISPLAY=:${find_display_num} is taken, searching for another..." 1>&3
396- selected_disp_num=" -1"
397- break
398- elif [ " ${selected_disp_num} " = " -1" ]; then
399- selected_disp_num=" ${find_display_num} "
400- echo " -- INFO: Possible free DISPLAY=:${find_display_num} " 1>&3
401- # echo "-- DEBUG: Updated selected_disp_num=$selected_disp_num" 1>&3
402- # echo "-- DEBUG: WAS read_disp_num=$read_disp_num" 1>&3
403- fi
404- done <<< " $(cat /tmp/netstatX11.log)"
405- else
406- # echo "-- INFO: Emtpy file /tmp/netstatX11.log" 1>&3
407- # selected_disp_num="${DEFAULT_DISP_N}"
408- selected_disp_num=" ${find_display_num} "
409- fi
410- if [ " ${selected_disp_num} " != " -1" ]; then
411- # If we can already use that display it means there is already some
412- # Xvfb there which means we need to keep looking for a free one.
413- export DISPLAY=" :${find_display_num} "
414- echo " ${DISPLAY} " > DISPLAY
415- if xsetroot -cursor_name left_ptr -fg white -bg black > /dev/null 2>&1 ; then
416- echo " -- WARN: DISPLAY=:${find_display_num} is already being used, skip it..." 1>&3
417- selected_disp_num=" -1"
418- fi
419- fi
420- if [ " ${selected_disp_num} " != " -1" ]; then
421- break
422- elif [ ${find_display_num} -gt ${MAX_DISPLAY_SEARCH} ]; then
423- echo " -- ERROR: Entered in an infinite loop at $0 after netstat" 1>&2 1>&3
424- selected_disp_num=" -1"
425- break
426- fi
427- done
428- [ " ${selected_disp_num} " = " -1" ] # || echo "-- INFO: Found free DISPLAY=:${selected_disp_num}" 1>&3
429-
430- export DISPLAY=" :${selected_disp_num} "
431- echo " ${DISPLAY} " > DISPLAY
432- echo ${selected_disp_num}
433- }
434-
435- function start_xvfb() {
436- # Start the X server that can run on machines with no real display
437- # using Xvfb instead of Xdummy
438- # echo "-- INFO: Will try to start Xvfb at DISPLAY=${DISPLAY}" 1>&3
439- # if DEBUG = true ...
440- # echo "Will use the following values for Xvfb"
441- # echo " screen=${SCREEN_NUM} geometry=${GEOMETRY}"
442- # echo " XVFB_CLI_OPTS_TCP=${XVFB_CLI_OPTS_TCP}"
443- # echo " XVFB_CLI_OPTS_BASE=${XVFB_CLI_OPTS_BASE}"
444- # echo " XVFB_CLI_OPTS_EXT=${XVFB_CLI_OPTS_EXT}"
445- Xvfb ${DISPLAY} -screen ${SCREEN_NUM} ${GEOMETRY} \
446- ${XVFB_CLI_OPTS_TCP} ${XVFB_CLI_OPTS_BASE} ${XVFB_CLI_OPTS_EXT} \
447- 1> " ${LOGS_DIR} /xvfb-tryouts-stdout.log" \
448- 2> " ${LOGS_DIR} /xvfb-tryouts-stderr.log" &
449- }
450-
451- if [ ! -z " ${XE_DISP_NUM} " ]; then
452- echo " INFO: XE_DISP_NUM '${XE_DISP_NUM} ' was provided so switching to that DISPLAY"
453- echo " INFO: and skipping virtual framebuffer startup in favor of remote."
454- export DISP_N=" ${XE_DISP_NUM} "
455- export DISPLAY=" :${DISP_N} "
456- start_xvfb
457- # elif [ "${PICK_ALL_RANDOM_PORTS}" = "true" ] || [ "${DISP_N}" = "-1" ]; then
458- else
459- # Find a free DISPLAY port starting with current DISP_N if any
460- i=0
461- while true ; do
462- let i=${i} +1
463- export DISP_N=$( get_free_display)
464- export DISPLAY=" :${DISP_N} "
465- echo " ${DISPLAY} " > DISPLAY
466- export XEPHYR_DISPLAY=" :${DISP_N} "
467- if ! start_xvfb; then
468- echo " -- WARN: start_xvfb() failed!" 1>&3
469- fi
470- if timeout --foreground " ${WAIT_FOREGROUND_RETRY} " wait-xvfb.sh & > " ${LOGS_DIR} /wait-xvfb-stdout.log" ; then
471- break
472- else
473- echo " -- WARN: wait-xvfb.sh failed! for DISPLAY=${DISPLAY} " 1>&3
474- fi
475- if [ ${i} -gt ${MAX_DISPLAY_SEARCH} ]; then
476- echo " -- ERROR: Failed to start Xvfb at $0 after many retries." 1>&2 1>&3
477- break
478- fi
479- done
480- # else
481- # export XEPHYR_DISPLAY=":${DISP_N}"
482- # export DISPLAY=":${DISP_N}"
483- # start_xvfb
484- fi
485-
486-
487- # Validations
488- if [ " :$DISP_N " != " ${DISPLAY} " ]; then
489- echo " FATAL: DISP_N '${DISP_N} ' doesn't match DISPLAY '${DISPLAY} '" 1>&2
490- exit 122
491- fi
492-
493369# -------------------------------
494370# Fix small tiny 64mb shm issue
495371# -------------------------------
@@ -500,6 +376,10 @@ if [ "${SHM_TRY_MOUNT_UNMOUNT}" = "true" ]; then
500376 tmpfs /dev/shm || true
501377fi
502378
379+ start-xvfb.sh
380+ export DISPLAY=" $( cat DISPLAY) "
381+ export DISP_N=" $( cat DISP_N) "
382+
503383# -------------------------------------------
504384# Keep updated environment vars inside files
505385# -------------------------------------------
0 commit comments