diff --git a/features/src/desktop-lite/devcontainer-feature.json b/features/src/desktop-lite/devcontainer-feature.json index f369bd1e..b9fe0e81 100644 --- a/features/src/desktop-lite/devcontainer-feature.json +++ b/features/src/desktop-lite/devcontainer-feature.json @@ -2,7 +2,7 @@ "id": "desktop-lite", "name": "Desktop Lite", "description": "A lightweight desktop environment for development.", - "version": "1.1.0", + "version": "1.1.1", "documentationURL": "https://github.com/Automattic/vip-codespaces/tree/trunk/features/src/desktop-lite", "containerEnv": { "DISPLAY": "127.0.0.1:0" diff --git a/features/src/desktop-lite/entrypoint.tpl b/features/src/desktop-lite/entrypoint.tpl index 7c80cd1d..c7e1702b 100755 --- a/features/src/desktop-lite/entrypoint.tpl +++ b/features/src/desktop-lite/entrypoint.tpl @@ -14,5 +14,17 @@ fi # shellcheck disable=SC2154,SC2086 su -s /bin/sh -c "/usr/bin/Xtigervnc -geometry \"${VNC_GEOMETRY}\" -listen tcp -ac ${AUTH_OPTS} -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -SendCutText -AcceptCutText :0" "${_REMOTE_USER}" & + +cnt=0 +while [ ! -S /tmp/.X11-unix/X0 ] && [ "${cnt}" -lt 10 ]; do + sleep 1 + cnt=$((cnt + 1)) +done + +if [ ! -S /tmp/.X11-unix/X0 ]; then + echo "Xtigervnc did not make display :0 available" >&2 + exit 1 +fi + DISPLAY=:0 su -s /bin/sh -c '/usr/bin/openbox' "${_REMOTE_USER}" & su -s /bin/sh -c '/usr/local/bin/easy-novnc -a :5800 -h 127.0.0.1 --no-url-password' "${_REMOTE_USER}" & diff --git a/features/test/desktop-lite/checks.sh b/features/test/desktop-lite/checks.sh index 6b38e09e..4a0eeb02 100755 --- a/features/test/desktop-lite/checks.sh +++ b/features/test/desktop-lite/checks.sh @@ -1,50 +1,41 @@ #!/bin/bash +# Wait for the X server to be available before running checks +cnt=0 +while [[ ! -S /tmp/.X11-unix/X0 ]] && [[ "${cnt}" -lt 10 ]]; do + sleep 1 + cnt=$((cnt + 1)) +done + +cnt=0 +while ! pgrep openbox > /dev/null 2>&1 && [[ "${cnt}" -lt 5 ]]; do + sleep 1 + cnt=$((cnt + 1)) +done + +cnt=0 +while ! pgrep easy-novnc > /dev/null 2>&1 && [[ "${cnt}" -lt 5 ]]; do + sleep 1 + cnt=$((cnt + 1)) +done + if hash sv > /dev/null 2>&1; then check "tigervnc is running" sudo sh -c 'sv status tigervnc | grep -E ^run:' sudo sv stop tigervnc check "tigervnc is stopped" sudo sh -c 'sv status tigervnc | grep -E ^down:' sudo sv start tigervnc - # shellcheck disable=SC2034 - for i in {1..10}; do - # shellcheck disable=SC2312 - sudo sv status tigervnc | grep -Eq '^run:' && break - sleep 1 - done check "tigervnc is running" sudo sh -c 'sv status tigervnc | grep -E ^run:' - # shellcheck disable=SC2312 - if ! sudo sv status openbox | grep -E ^run:; then - sudo ps faux - sudo cat /var/log/* - fi check "openbox is running" sudo sh -c 'sv status openbox | grep -E ^run:' sudo sv stop openbox check "openbox is stopped" sudo sh -c 'sv status openbox | grep -E ^down:' sudo sv start openbox - # shellcheck disable=SC2034 - for i in {1..10}; do - # shellcheck disable=SC2312 - sudo sv status openbox | grep -Eq '^run:' && break - sleep 1 - done - # shellcheck disable=SC2312 - if ! sudo sv status openbox | grep -E ^run:; then - sudo ps faux - sudo cat /var/log/* - fi check "openbox is running" sudo sh -c 'sv status openbox | grep -E ^run:' check "novnc is running" sudo sh -c 'sv status novnc | grep -E ^run:' sudo sv stop novnc check "novnc is stopped" sudo sh -c 'sv status novnc | grep -E ^down:' sudo sv start novnc - # shellcheck disable=SC2034 - for i in {1..10}; do - # shellcheck disable=SC2312 - sudo sv status novnc | grep -Eq '^run:' && break - sleep 1 - done check "novnc is running" sudo sh -c 'sv status novnc | grep -E ^run:' else check "tigervnc is running" pgrep Xtigervnc