Skip to content

Commit

Permalink
Revert: Robust display detection (#916) (#978)
Browse files Browse the repository at this point in the history
Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
  • Loading branch information
Crola1702 committed Jul 31, 2023
1 parent 6807516 commit 45cf243
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions jenkins-scripts/lib/check_graphic_card.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ GRAPHIC_CARD_PKG=""

export_display_variable()
{
# Check for an active X11 display socket.
for i in $(find /tmp/.X11-unix -type s)
# Hack to found the current display (if available) two steps:
# Check for /tmp/.X11-unix/ socket and check if the process is running
for i in $(ls /tmp/.X11-unix/ | sed -e 's@^X@:@')
do
# If a process is running with the open socket then
# lsof will exit successfully.
if sudo bash -c "lsof -Fp $i" ; then
# Strip the path and leading X from the X11 socket
# but check that the resulting string is numeric and
# non-empty before exporting.
DISPLAY=:$(basename $i | sed -n -E 's/^X([0-9]+)/:\1/p')
if [ -n "$DISPLAY" ]; then
export DISPLAY
fi
# grep can fail so let's disable the fail or error during its call
set +e
ps aux | grep bin/X.*$i | grep -v grep
set -e
if [ $? -eq 0 ] ; then
export DISPLAY=$i
fi
done
}
Expand Down Expand Up @@ -82,9 +79,7 @@ if $GPU_SUPPORT_NEEDED; then
if [[ ${DISPLAY} == "" ]]; then
echo "GPU support needed by the script but DISPLAY var is empty"
# Try to restart lightdm. It should stop the script in the case of failure
sudo systemctl restart lightdm
# Wait for lightdm service to restart X11.
sleep 5
sudo service lightdm restart
# Second try to get display variable
export_display_variable
if [[ ${DISPLAY} == "" ]]; then
Expand Down

0 comments on commit 45cf243

Please sign in to comment.