Skip to content

Commit 14a4c4c

Browse files
authored
[desktop-lite] - Adding support for noVnc latest version in the feature (#1395)
* [desktop-lite] - Adding support for noVNC latest version in the feature * Corrections based on review comments. * Correcting the logger statement.
1 parent 636f6db commit 14a4c4c

File tree

4 files changed

+65
-8
lines changed

4 files changed

+65
-8
lines changed

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: 21 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,20 @@ 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+
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
398+
if version_gt "${NOVNC_VERSION}" "1.2.0"; then
399+
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/novnc_proxy --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
400+
log "noVNC started with novnc_proxy."
401+
else
402+
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
403+
log "noVNC started with launch.sh."
404+
fi
405+
else
406+
log "noVNC is already running."
407+
fi
392408
else
393-
log "noVNC is already running or not installed."
409+
log "noVNC is not installed."
394410
fi
395411
396412
# 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)