From 81e9d753b59a2bc10f06b2f13c6733ef886fe203 Mon Sep 17 00:00:00 2001 From: The Anh Nguyen Date: Wed, 12 Feb 2025 13:31:19 +0700 Subject: [PATCH] fix CiaB VNC --- .../cdn-in-a-box/optional/vnc/Dockerfile | 3 ++- .../cdn-in-a-box/optional/vnc/run.sh | 22 ++++++++++++++++++- .../cdn-in-a-box/optional/vnc/vnc_startup.sh | 18 +++++---------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/infrastructure/cdn-in-a-box/optional/vnc/Dockerfile b/infrastructure/cdn-in-a-box/optional/vnc/Dockerfile index f869e82d46..c94a8eb6ba 100644 --- a/infrastructure/cdn-in-a-box/optional/vnc/Dockerfile +++ b/infrastructure/cdn-in-a-box/optional/vnc/Dockerfile @@ -30,7 +30,8 @@ ENV VNC_USER=$VNC_BUILD_USER RUN dnf -y install "https://download1.rpmfusion.org/free/el/rpmfusion-free-release-${RHEL_VERSION%%.*}.noarch.rpm" epel-release && \ dnf -y install xterm firefox git tigervnc-server sudo bind-utils net-tools which passwd which \ - fluxbox 'google-noto*' terminus-fonts tigervnc vlc wget openssl curl nc && \ + fluxbox 'google-noto*' terminus-fonts tigervnc vlc wget openssl curl nc \ + xorg-x11-server-utils xorg-x11-fonts* && \ dnf -y clean all && rm -rf /var/cache/dnf RUN if [[ "${RHEL_VERSION%%.*}" -ge 8 ]]; then \ diff --git a/infrastructure/cdn-in-a-box/optional/vnc/run.sh b/infrastructure/cdn-in-a-box/optional/vnc/run.sh index bcaa41fd11..7462218519 100755 --- a/infrastructure/cdn-in-a-box/optional/vnc/run.sh +++ b/infrastructure/cdn-in-a-box/optional/vnc/run.sh @@ -58,6 +58,26 @@ else sleep 1 fi -su -c "vncserver :$VNC_INSTANCE_NUM -depth $VNC_DEPTH -geometry $VNC_RESOLUTION" - "$VNC_USER" +su -c "Xvnc :$VNC_INSTANCE_NUM -depth $VNC_DEPTH -geometry $VNC_RESOLUTION -rfbauth /home/$VNC_USER/.vnc/passwd &" - "$VNC_USER" + +# Wait a moment for Xvnc to start +sleep 2 + +# Set DISPLAY environment variable +export DISPLAY=:$VNC_INSTANCE_NUM + +# Wait for Traffic Portal to be available +until nc 'trafficportal.infra.ciab.test' 443 /dev/null 2>&1; do + echo "Waiting for Traffic Portal to start" + sleep 2 +done + +# Start Fluxbox and desktop components +su -c "DISPLAY=:$VNC_INSTANCE_NUM fluxbox &" - "$VNC_USER" +su -c "DISPLAY=:$VNC_INSTANCE_NUM xterm &" - "$VNC_USER" +su -c "DISPLAY=:$VNC_INSTANCE_NUM firefox https://trafficportal.infra.ciab.test &" - "$VNC_USER" + +# Set a nice background color +su -c "DISPLAY=:$VNC_INSTANCE_NUM xsetroot -solid '#4A7AA7' &" - "$VNC_USER" tail -F -- /home/ciabuser/.vnc/vnc*:9.log diff --git a/infrastructure/cdn-in-a-box/optional/vnc/vnc_startup.sh b/infrastructure/cdn-in-a-box/optional/vnc/vnc_startup.sh index 5010411a12..bb2b7dfcc0 100755 --- a/infrastructure/cdn-in-a-box/optional/vnc/vnc_startup.sh +++ b/infrastructure/cdn-in-a-box/optional/vnc/vnc_startup.sh @@ -16,19 +16,11 @@ # specific language governing permissions and limitations # under the License. -VNC_DEPTH=${VNC_DEPTH:-32} -VNC_RESOLUTION=${VNC_DEPTH:-1440x900} +# startfluxbox & -startfluxbox & - -sleep 3 +# sleep 3 vncconfig -iconic & -xterm -bg black -fg white +sb & - -until nc 'trafficportal.infra.ciab.test' 443 /dev/null 2>&1; do - echo "Waiting for Traffic Portal to start" - sleep 2 -done - -firefox 'http://trafficportal.infra.ciab.test' & +fluxbox & +xsetroot -solid '#4A7AA7' & +xterm &