Skip to content

Commit 9a72159

Browse files
committed
[desktop-lite] - Adding support for noVNC latest version in the feature
1 parent e8784d1 commit 9a72159

4 files changed

Lines changed: 66 additions & 8 deletions

File tree

src/desktop-lite/devcontainer-feature.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "desktop-lite",
3-
"version": "1.2.6",
3+
"version": "1.2.7",
44
"name": "Light-weight Desktop",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite",
66
"description": "Adds a lightweight Fluxbox based desktop to the container that can be accessed using a VNC viewer or the web. GUI-based commands executed from the built-in VS code terminal will open on the desktop automatically.",
@@ -16,9 +16,9 @@
1616
"noVncVersion": {
1717
"type": "string",
1818
"proposals": [
19-
"1.2.0"
19+
"1.6.0"
2020
],
21-
"default": "1.2.0",
21+
"default": "1.6.0",
2222
"description": "The noVNC version to use"
2323
},
2424
"password": {

src/desktop-lite/install.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/desktop-lite.md
88
# Maintainer: The VS Code and Codespaces Teams
99

10-
NOVNC_VERSION="${NOVNCVERSION:-"1.2.0"}" # TODO: Add in a 'latest' auto-detect and swap name to 'version'
10+
NOVNC_VERSION="${NOVNCVERSION:-"1.6.0"}" # TODO: Add in a 'latest' auto-detect and swap name to 'version'
1111
VNC_PASSWORD=${PASSWORD:-"vscode"}
1212
if [ "$VNC_PASSWORD" = "noPassword" ]; then
1313
unset VNC_PASSWORD
@@ -355,6 +355,13 @@ log()
355355
echo -e "[\$(date)] \$@" | sudoIf tee -a \$LOG > /dev/null
356356
}
357357
358+
# Function to compare versions
359+
version_gt() {
360+
# returns 0 if \$1 > \$2
361+
[ "\$(printf '%s\n' "\$2" "\$1" | sort -V | head -n1)" != "\$1" ]
362+
}
363+
364+
358365
log "** SCRIPT START **"
359366
360367
# Start dbus.
@@ -386,11 +393,21 @@ else
386393
fi
387394
388395
# Spin up noVNC if installed and not running.
389-
if [ -d "/usr/local/novnc" ] && [ "\$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
390-
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
391-
log "noVNC started."
396+
if [ -d "/usr/local/novnc" ]; then
397+
NOVNC_VERSION_INSTALLED=\$(ls /usr/local/novnc | grep -oP 'noVNC-\K[0-9.]+' | head -n1)
398+
if [ "\$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ] && [ "\$(ps -ef | grep /usr/local/novnc/noVNC*/utils/novnc_proxy | grep -v grep)" = "" ]; then
399+
if version_gt "\$NOVNC_VERSION_INSTALLED" "1.2.0"; then
400+
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/novnc_proxy --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
401+
log "noVNC started with novnc_proxy."
402+
else
403+
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
404+
log "noVNC started with launch.sh."
405+
fi
406+
else
407+
log "noVNC is already running or not installed."
408+
fi
392409
else
393-
log "noVNC is already running or not installed."
410+
log "noVNC is not installed."
394411
fi
395412
396413
# Run whatever was passed in

test/desktop-lite/scenarios.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
"desktop-lite": {}
66
}
77
},
8+
"test_xtigervnc_novnc_started_noVNC_old_launch_script": {
9+
"image": "ubuntu:noble",
10+
"features": {
11+
"desktop-lite": {
12+
"noVncVersion": "1.2.0"
13+
}
14+
}
15+
},
816
"test_vnc_resolution_as_container_env_var": {
917
"image": "ubuntu:noble",
1018
"features": {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Check if xtigervnc & noVnc processes are running after successful installation and initialization
9+
check_process_running() {
10+
port=$1
11+
# Get process id of process running on specific port
12+
PID=$(lsof -i :$port | awk 'NR==2 {print $2}')
13+
if [ -n "$PID" ]; then
14+
CMD=$(ps -p $PID -o cmd --no-headers)
15+
GREEN='\033[0;32m'; NC='\033[0m'; RED='\033[0;31m'; YELLOW='\033[0;33m';
16+
echo -e "${GREEN}Command running on port $port: ${YELLOW}$CMD${NC}"
17+
else
18+
echo -e "${RED}No process found listening on port $port.${NC}"
19+
fi
20+
}
21+
22+
check "Whether xtigervnc is Running" check_process_running 5901
23+
sleep 1
24+
check "Whether no_vnc is Running" check_process_running 6080
25+
26+
check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
27+
check "log-exists" bash -c "ls /tmp/container-init.log"
28+
check "log file contents" bash -c "cat /tmp/container-init.log"
29+
30+
# Report result
31+
reportResults
32+
33+

0 commit comments

Comments
 (0)