Unverified Commit 9b189037 authored by Samruddhi Khandale's avatar Samruddhi Khandale Committed by GitHub

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 f5f489f6.
parent 8f3115af
{ {
"id": "desktop-lite", "id": "desktop-lite",
"version": "1.2.2", "version": "1.2.3",
"name": "Light-weight Desktop", "name": "Light-weight Desktop",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite", "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.", "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.",
......
...@@ -293,7 +293,7 @@ echo -e "\nSuccess!\n" ...@@ -293,7 +293,7 @@ echo -e "\nSuccess!\n"
EOF EOF
# Container ENTRYPOINT script # Container ENTRYPOINT script
cat << 'EOF' > /usr/local/share/desktop-init.sh cat << EOF > /usr/local/share/desktop-init.sh
#!/bin/bash #!/bin/bash
user_name="${USERNAME}" user_name="${USERNAME}"
...@@ -309,67 +309,50 @@ export LANGUAGE="${LANGUAGE:-"en_US.UTF-8"}" ...@@ -309,67 +309,50 @@ export LANGUAGE="${LANGUAGE:-"en_US.UTF-8"}"
# Execute the command it not already running # Execute the command it not already running
startInBackgroundIfNotRunning() startInBackgroundIfNotRunning()
{ {
log "Starting $1." log "Starting \$1."
echo -e "\n** $(date) **" | sudoIf tee -a /tmp/\$1.log > /dev/null echo -e "\n** \$(date) **" | sudoIf tee -a /tmp/\$1.log > /dev/null
if ! pgrep -x $1 > /dev/null; then if ! pgrep -x \$1 > /dev/null; then
keepRunningInBackground "$@" keepRunningInBackground "\$@"
while ! pgrep -x $1 > /dev/null; do while ! pgrep -x \$1 > /dev/null; do
sleep 1 sleep 1
done done
log "$1 started." log "\$1 started."
else else
echo "$1 is already running." | sudoIf tee -a /tmp/\$1.log > /dev/null echo "\$1 is already running." | sudoIf tee -a /tmp/\$1.log > /dev/null
log "$1 is already running." log "\$1 is already running."
fi fi
} }
# Keep command running in background # Keep command running in background
keepRunningInBackground() 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)
}
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 # Use sudo to run as root when required
sudoIf() sudoIf()
{ {
if [ "$(id -u)" -ne 0 ]; then if [ "\$(id -u)" -ne 0 ]; then
check_packages sudo sudo "\$@"
sudo "$@"
else else
"$@" "\$@"
fi fi
} }
# Use sudo to run as non-root user if not already running # Use sudo to run as non-root user if not already running
sudoUserIf() sudoUserIf()
{ {
if [ "$(id -u)" -eq 0 ] && [ "${user_name}" != "root" ]; then if [ "\$(id -u)" -eq 0 ] && [ "\${user_name}" != "root" ]; then
check_packages sudo sudo -u \${user_name} "\$@"
sudo -u "${user_name}" "$@"
else else
"$@" "\$@"
fi fi
} }
# Log messages # Log messages
log() log()
{ {
echo -e "[$(date)] $@" | sudoIf tee -a $LOG > /dev/null echo -e "[\$(date)] \$@" | sudoIf tee -a \$LOG > /dev/null
} }
log "** SCRIPT START **" log "** SCRIPT START **"
...@@ -388,22 +371,22 @@ done ...@@ -388,22 +371,22 @@ done
sudoIf rm -rf /tmp/.X11-unix /tmp/.X*-lock sudoIf rm -rf /tmp/.X11-unix /tmp/.X*-lock
mkdir -p /tmp/.X11-unix mkdir -p /tmp/.X11-unix
sudoIf chmod 1777 /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 if [ "\$(echo "\${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\${VNC_RESOLUTION}x16; fi
screen_geometry="${VNC_RESOLUTION%*x*}" screen_geometry="\${VNC_RESOLUTION%*x*}"
screen_depth="${VNC_RESOLUTION##*x}" screen_depth="\${VNC_RESOLUTION##*x}"
# Check if VNC_PASSWORD is set and use the appropriate command # 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 if [ -n "\${VNC_PASSWORD+x}" ]; then
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd" startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "\${common_options} -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
else else
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "${common_options} -SecurityTypes None" startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "\${common_options} -SecurityTypes None"
fi fi
# Spin up noVNC if installed and not running. # 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}" keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
log "noVNC started." log "noVNC started."
else else
...@@ -411,7 +394,7 @@ else ...@@ -411,7 +394,7 @@ else
fi fi
# Run whatever was passed in # Run whatever was passed in
log "Executing \"$@\"." log "Executing \"\$@\"."
exec "$@" exec "$@"
log "** SCRIPT EXIT **" log "** SCRIPT EXIT **"
EOF EOF
......
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