Unverified Commit 14a4c4c2 authored by Kaniska's avatar Kaniska Committed by GitHub

[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.
parent 636f6db0
{
"id": "desktop-lite",
"version": "1.2.6",
"version": "1.2.7",
"name": "Light-weight Desktop",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite",
"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 @@
"noVncVersion": {
"type": "string",
"proposals": [
"1.2.0"
"1.6.0"
],
"default": "1.2.0",
"default": "1.6.0",
"description": "The noVNC version to use"
},
"password": {
......
......@@ -7,7 +7,7 @@
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/desktop-lite.md
# Maintainer: The VS Code and Codespaces Teams
NOVNC_VERSION="${NOVNCVERSION:-"1.2.0"}" # TODO: Add in a 'latest' auto-detect and swap name to 'version'
NOVNC_VERSION="${NOVNCVERSION:-"1.6.0"}" # TODO: Add in a 'latest' auto-detect and swap name to 'version'
VNC_PASSWORD=${PASSWORD:-"vscode"}
if [ "$VNC_PASSWORD" = "noPassword" ]; then
unset VNC_PASSWORD
......@@ -355,6 +355,13 @@ log()
echo -e "[\$(date)] \$@" | sudoIf tee -a \$LOG > /dev/null
}
# Function to compare versions
version_gt() {
# returns 0 if \$1 > \$2
[ "\$(printf '%s\n' "\$2" "\$1" | sort -V | head -n1)" != "\$1" ]
}
log "** SCRIPT START **"
# Start dbus.
......@@ -386,11 +393,20 @@ else
fi
# Spin up noVNC if installed and not running.
if [ -d "/usr/local/novnc" ] && [ "\$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
if [ -d "/usr/local/novnc" ]; then
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
if version_gt "${NOVNC_VERSION}" "1.2.0"; then
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/novnc_proxy --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
log "noVNC started with novnc_proxy."
else
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
log "noVNC started."
log "noVNC started with launch.sh."
fi
else
log "noVNC is already running."
fi
else
log "noVNC is already running or not installed."
log "noVNC is not installed."
fi
# Run whatever was passed in
......
......@@ -5,6 +5,14 @@
"desktop-lite": {}
}
},
"test_xtigervnc_novnc_started_noVNC_old_launch_script": {
"image": "ubuntu:noble",
"features": {
"desktop-lite": {
"noVncVersion": "1.2.0"
}
}
},
"test_vnc_resolution_as_container_env_var": {
"image": "ubuntu:noble",
"features": {
......
#!/bin/bash
set -e
# Optional: Import test library
source dev-container-features-test-lib
# Check if xtigervnc & noVnc processes are running after successful installation and initialization
check_process_running() {
port=$1
# Get process id of process running on specific port
PID=$(lsof -i :$port | awk 'NR==2 {print $2}')
if [ -n "$PID" ]; then
CMD=$(ps -p $PID -o cmd --no-headers)
GREEN='\033[0;32m'; NC='\033[0m'; RED='\033[0;31m'; YELLOW='\033[0;33m';
echo -e "${GREEN}Command running on port $port: ${YELLOW}$CMD${NC}"
else
echo -e "${RED}No process found listening on port $port.${NC}"
fi
}
check "Whether xtigervnc is Running" check_process_running 5901
sleep 1
check "Whether no_vnc is Running" check_process_running 6080
check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
check "log-exists" bash -c "ls /tmp/container-init.log"
check "log file contents" bash -c "cat /tmp/container-init.log"
# Report result
reportResults
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment