Skip to content

Commit 9b18903

Browse files
Revert "[Desktop-lite] - VNC_RESOLUTION unreadable fix - issue #945 fix (#1024) (#1088)
Revert "[Desktop-lite] - VNC_RESOLUTION unreadable fix - issue #945 fix (#1024)" This reverts commit f5f489f.
1 parent 8f3115a commit 9b18903

File tree

2 files changed

+28
-45
lines changed

2 files changed

+28
-45
lines changed

src/desktop-lite/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "desktop-lite",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
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.",

src/desktop-lite/install.sh

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ echo -e "\nSuccess!\n"
293293
EOF
294294

295295
# Container ENTRYPOINT script
296-
cat << 'EOF' > /usr/local/share/desktop-init.sh
296+
cat << EOF > /usr/local/share/desktop-init.sh
297297
#!/bin/bash
298298
299299
user_name="${USERNAME}"
@@ -309,67 +309,50 @@ export LANGUAGE="${LANGUAGE:-"en_US.UTF-8"}"
309309
# Execute the command it not already running
310310
startInBackgroundIfNotRunning()
311311
{
312-
log "Starting $1."
313-
echo -e "\n** $(date) **" | sudoIf tee -a /tmp/\$1.log > /dev/null
314-
if ! pgrep -x $1 > /dev/null; then
315-
keepRunningInBackground "$@"
316-
while ! pgrep -x $1 > /dev/null; do
312+
log "Starting \$1."
313+
echo -e "\n** \$(date) **" | sudoIf tee -a /tmp/\$1.log > /dev/null
314+
if ! pgrep -x \$1 > /dev/null; then
315+
keepRunningInBackground "\$@"
316+
while ! pgrep -x \$1 > /dev/null; do
317317
sleep 1
318318
done
319-
log "$1 started."
319+
log "\$1 started."
320320
else
321-
echo "$1 is already running." | sudoIf tee -a /tmp/\$1.log > /dev/null
322-
log "$1 is already running."
321+
echo "\$1 is already running." | sudoIf tee -a /tmp/\$1.log > /dev/null
322+
log "\$1 is already running."
323323
fi
324324
}
325325
326326
# Keep command running in background
327327
keepRunningInBackground()
328328
{
329-
($2 bash -c "while :; do echo [\\$(date)] Process started.; $3; echo [\\$(date)] Process exited!; sleep 5; done 2>&1" | sudoIf tee -a /tmp/\$1.log > /dev/null & echo "\$!" | sudoIf tee /tmp/\$1.pid > /dev/null)
330-
}
331-
332-
apt_get_update()
333-
{
334-
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
335-
echo "Running apt-get update..."
336-
apt-get update -y
337-
fi
338-
}
339-
340-
check_packages() {
341-
if ! dpkg -s "$@" > /dev/null 2>&1; then
342-
apt_get_update
343-
apt-get -y install --no-install-recommends "$@"
344-
fi
329+
(\$2 bash -c "while :; do echo [\\\$(date)] Process started.; \$3; echo [\\\$(date)] Process exited!; sleep 5; done 2>&1" | sudoIf tee -a /tmp/\$1.log > /dev/null & echo "\$!" | sudoIf tee /tmp/\$1.pid > /dev/null)
345330
}
346331
347332
# Use sudo to run as root when required
348333
sudoIf()
349334
{
350-
if [ "$(id -u)" -ne 0 ]; then
351-
check_packages sudo
352-
sudo "$@"
335+
if [ "\$(id -u)" -ne 0 ]; then
336+
sudo "\$@"
353337
else
354-
"$@"
338+
"\$@"
355339
fi
356340
}
357341
358342
# Use sudo to run as non-root user if not already running
359343
sudoUserIf()
360344
{
361-
if [ "$(id -u)" -eq 0 ] && [ "${user_name}" != "root" ]; then
362-
check_packages sudo
363-
sudo -u "${user_name}" "$@"
345+
if [ "\$(id -u)" -eq 0 ] && [ "\${user_name}" != "root" ]; then
346+
sudo -u \${user_name} "\$@"
364347
else
365-
"$@"
348+
"\$@"
366349
fi
367350
}
368351
369352
# Log messages
370353
log()
371354
{
372-
echo -e "[$(date)] $@" | sudoIf tee -a $LOG > /dev/null
355+
echo -e "[\$(date)] \$@" | sudoIf tee -a \$LOG > /dev/null
373356
}
374357
375358
log "** SCRIPT START **"
@@ -388,30 +371,30 @@ done
388371
sudoIf rm -rf /tmp/.X11-unix /tmp/.X*-lock
389372
mkdir -p /tmp/.X11-unix
390373
sudoIf chmod 1777 /tmp/.X11-unix
391-
sudoIf chown root:${group_name} /tmp/.X11-unix
392-
if [ "$(echo "${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=${VNC_RESOLUTION}x16; fi
393-
screen_geometry="${VNC_RESOLUTION%*x*}"
394-
screen_depth="${VNC_RESOLUTION##*x}"
374+
sudoIf chown root:\${group_name} /tmp/.X11-unix
375+
if [ "\$(echo "\${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\${VNC_RESOLUTION}x16; fi
376+
screen_geometry="\${VNC_RESOLUTION%*x*}"
377+
screen_depth="\${VNC_RESOLUTION##*x}"
395378
396379
# Check if VNC_PASSWORD is set and use the appropriate command
397-
common_options="tigervncserver ${DISPLAY} -geometry ${screen_geometry} -depth ${screen_depth} -rfbport ${VNC_PORT} -dpi ${VNC_DPI:-96} -localhost -desktop fluxbox -fg"
380+
common_options="tigervncserver \${DISPLAY} -geometry \${screen_geometry} -depth \${screen_depth} -rfbport ${VNC_PORT} -dpi \${VNC_DPI:-96} -localhost -desktop fluxbox -fg"
398381
399-
if [ -n "${VNC_PASSWORD+x}" ]; then
400-
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
382+
if [ -n "\${VNC_PASSWORD+x}" ]; then
383+
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "\${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
401384
else
402-
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -SecurityTypes None"
385+
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "\${common_options} -SecurityTypes None"
403386
fi
404387
405388
# Spin up noVNC if installed and not running.
406-
if [ -d "/usr/local/novnc" ] && [ "$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
389+
if [ -d "/usr/local/novnc" ] && [ "\$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
407390
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
408391
log "noVNC started."
409392
else
410393
log "noVNC is already running or not installed."
411394
fi
412395
413396
# Run whatever was passed in
414-
log "Executing \"$@\"."
397+
log "Executing \"\$@\"."
415398
exec "$@"
416399
log "** SCRIPT EXIT **"
417400
EOF

0 commit comments

Comments
 (0)