|
7 | 7 | # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/desktop-lite.md |
8 | 8 | # Maintainer: The VS Code and Codespaces Teams |
9 | 9 |
|
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' |
11 | 11 | VNC_PASSWORD=${PASSWORD:-"vscode"} |
12 | 12 | if [ "$VNC_PASSWORD" = "noPassword" ]; then |
13 | 13 | unset VNC_PASSWORD |
@@ -355,6 +355,13 @@ log() |
355 | 355 | echo -e "[\$(date)] \$@" | sudoIf tee -a \$LOG > /dev/null |
356 | 356 | } |
357 | 357 |
|
| 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 | +
|
358 | 365 | log "** SCRIPT START **" |
359 | 366 |
|
360 | 367 | # Start dbus. |
@@ -386,11 +393,20 @@ else |
386 | 393 | fi |
387 | 394 |
|
388 | 395 | # 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 |
392 | 408 | else |
393 | | - log "noVNC is already running or not installed." |
| 409 | + log "noVNC is not installed." |
394 | 410 | fi |
395 | 411 |
|
396 | 412 | # Run whatever was passed in |
|
0 commit comments