From 4c0622431ff101e7a2e24187d78c9e3596956ba5 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:29:16 +0000 Subject: [PATCH 1/8] [Desktop-lite] - VNC_RESOLUTION unreadable fix - issue #945 --- src/desktop-lite/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index ef8b603c6..9878f7e38 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -293,7 +293,7 @@ echo -e "\nSuccess!\n" EOF # Container ENTRYPOINT script -cat << EOF > /usr/local/share/desktop-init.sh +cat << 'EOF' > /usr/local/share/desktop-init.sh #!/bin/bash user_name="${USERNAME}" From 4381eb8c7dd24bc174f4644b456b329797b20abd Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Fri, 28 Jun 2024 22:35:26 +0000 Subject: [PATCH 2/8] bump to patch version done --- src/desktop-lite/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/desktop-lite/devcontainer-feature.json b/src/desktop-lite/devcontainer-feature.json index 417787c51..2dee08bde 100644 --- a/src/desktop-lite/devcontainer-feature.json +++ b/src/desktop-lite/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "desktop-lite", - "version": "1.2.0", + "version": "1.2.1", "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.", From cd4878853e56ffd71ec9c288738f1ef3c80a1271 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Tue, 30 Jul 2024 01:12:32 +0000 Subject: [PATCH 3/8] changes as suggested --- src/desktop-lite/install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index 9878f7e38..77666f084 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -332,20 +332,20 @@ keepRunningInBackground() # Use sudo to run as root when required sudoIf() { - if [ "\$(id -u)" -ne 0 ]; then - sudo "\$@" + if [ "$(id -u)" -ne 0 ]; then + sudo "$@" else - "\$@" + "$@" fi } # Use sudo to run as non-root user if not already running sudoUserIf() { - if [ "\$(id -u)" -eq 0 ] && [ "\${user_name}" != "root" ]; then - sudo -u \${user_name} "\$@" + if [ "$(id -u)" -eq 0 ] && [ "${user_name}" != "root" ]; then + sudo -u "${user_name}" "$@" else - "\$@" + "$@" fi } From 903bf6c904044fd0cb3cc2ab74bd193e6579c1a3 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:12:17 +0000 Subject: [PATCH 4/8] changes - removing escaped variables for init to go smoothly --- src/desktop-lite/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index 77666f084..b5819dda0 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -371,7 +371,7 @@ done sudoIf rm -rf /tmp/.X11-unix /tmp/.X*-lock mkdir -p /tmp/.X11-unix sudoIf chmod 1777 /tmp/.X11-unix -sudoIf chown root:\${group_name} /tmp/.X11-unix +sudoIf chown root:${group_name} /tmp/.X11-unix if [ "\$(echo "\${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\${VNC_RESOLUTION}x16; fi screen_geometry="\${VNC_RESOLUTION%*x*}" screen_depth="\${VNC_RESOLUTION##*x}" From 520b4ef2747c65336091551c639d60f50a4b6cb1 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:17:15 +0000 Subject: [PATCH 5/8] misc change --- src/desktop-lite/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index b5819dda0..83cd1cace 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -326,7 +326,7 @@ startInBackgroundIfNotRunning() # Keep command running in background keepRunningInBackground() { - (\$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) + ($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) } # Use sudo to run as root when required From c9e7b210b59a4d29c10346070f2204acb7db8d61 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:24:40 +0000 Subject: [PATCH 6/8] few more escaped vars - making them unescaped --- src/desktop-lite/install.sh | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index 83cd1cace..aa9d311c5 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -309,24 +309,24 @@ export LANGUAGE="${LANGUAGE:-"en_US.UTF-8"}" # Execute the command it not already running startInBackgroundIfNotRunning() { - log "Starting \$1." - echo -e "\n** \$(date) **" | sudoIf tee -a /tmp/\$1.log > /dev/null - if ! pgrep -x \$1 > /dev/null; then - keepRunningInBackground "\$@" - while ! pgrep -x \$1 > /dev/null; do + log "Starting $1." + echo -e "\n** $(date) **" | sudoIf tee -a /tmp/\$1.log > /dev/null + if ! pgrep -x $1 > /dev/null; then + keepRunningInBackground "$@" + while ! pgrep -x $1 > /dev/null; do sleep 1 done - log "\$1 started." + log "$1 started." else - echo "\$1 is already running." | sudoIf tee -a /tmp/\$1.log > /dev/null - log "\$1 is already running." + echo "$1 is already running." | sudoIf tee -a /tmp/\$1.log > /dev/null + log "$1 is already running." fi } # Keep command running in background keepRunningInBackground() { - ($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) + ($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) } # Use sudo to run as root when required @@ -352,7 +352,7 @@ sudoUserIf() # Log messages log() { - echo -e "[\$(date)] \$@" | sudoIf tee -a \$LOG > /dev/null + echo -e "[$(date)] $@" | sudoIf tee -a $LOG > /dev/null } log "** SCRIPT START **" @@ -372,21 +372,21 @@ sudoIf rm -rf /tmp/.X11-unix /tmp/.X*-lock mkdir -p /tmp/.X11-unix sudoIf chmod 1777 /tmp/.X11-unix sudoIf chown root:${group_name} /tmp/.X11-unix -if [ "\$(echo "\${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\${VNC_RESOLUTION}x16; fi -screen_geometry="\${VNC_RESOLUTION%*x*}" -screen_depth="\${VNC_RESOLUTION##*x}" +if [ "$(echo "${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=${VNC_RESOLUTION}x16; fi +screen_geometry="${VNC_RESOLUTION%*x*}" +screen_depth="${VNC_RESOLUTION##*x}" # Check if VNC_PASSWORD is set and use the appropriate command -common_options="tigervncserver \${DISPLAY} -geometry \${screen_geometry} -depth \${screen_depth} -rfbport ${VNC_PORT} -dpi \${VNC_DPI:-96} -localhost -desktop fluxbox -fg" +common_options="tigervncserver \${DISPLAY} -geometry ${screen_geometry} -depth ${screen_depth} -rfbport ${VNC_PORT} -dpi ${VNC_DPI:-96} -localhost -desktop fluxbox -fg" -if [ -n "\${VNC_PASSWORD+x}" ]; then - startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "\${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd" +if [ -n "${VNC_PASSWORD+x}" ]; then + startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd" else - startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "\${common_options} -SecurityTypes None" + startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -SecurityTypes None" 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" ] && [ "$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}" log "noVNC started." else @@ -395,7 +395,7 @@ fi # Run whatever was passed in log "Executing \"\$@\"." -exec "\$@" +exec "$@" log "** SCRIPT EXIT **" EOF From 6b2206e3fe30d7d179eb91ca5ae271cab48b5e0c Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Fri, 2 Aug 2024 08:11:11 +0000 Subject: [PATCH 7/8] misc changes --- src/desktop-lite/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index aa9d311c5..c604f9382 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -377,7 +377,7 @@ screen_geometry="${VNC_RESOLUTION%*x*}" screen_depth="${VNC_RESOLUTION##*x}" # Check if VNC_PASSWORD is set and use the appropriate command -common_options="tigervncserver \${DISPLAY} -geometry ${screen_geometry} -depth ${screen_depth} -rfbport ${VNC_PORT} -dpi ${VNC_DPI:-96} -localhost -desktop fluxbox -fg" +common_options="tigervncserver ${DISPLAY} -geometry ${screen_geometry} -depth ${screen_depth} -rfbport ${VNC_PORT} -dpi ${VNC_DPI:-96} -localhost -desktop fluxbox -fg" if [ -n "${VNC_PASSWORD+x}" ]; then startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd" @@ -394,7 +394,7 @@ else fi # Run whatever was passed in -log "Executing \"\$@\"." +log "Executing "\$@\"." exec "$@" log "** SCRIPT EXIT **" EOF From 54474058236d1581f57720f014c01d9c68b01f38 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Mon, 5 Aug 2024 06:18:57 +0000 Subject: [PATCH 8/8] changes for sudo - command not found error in few test cases --- src/desktop-lite/install.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index c604f9382..777be8f1a 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -329,10 +329,26 @@ keepRunningInBackground() ($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) } +apt_get_update() +{ + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +} + # Use sudo to run as root when required sudoIf() { if [ "$(id -u)" -ne 0 ]; then + check_packages sudo sudo "$@" else "$@" @@ -343,6 +359,7 @@ sudoIf() sudoUserIf() { if [ "$(id -u)" -eq 0 ] && [ "${user_name}" != "root" ]; then + check_packages sudo sudo -u "${user_name}" "$@" else "$@"