Skip to content

Commit

Permalink
Adding X11VNC setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrobey committed Oct 6, 2024
1 parent 403d366 commit b742888
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
: ${BUILD_SCOREP:="0"}
: ${BUILD_MPI4PY:="0"}
: ${BUILD_HPCTOOLKIT:="0"}
: ${BUILD_X11VNC:="0"}
: ${BUILD_ALL_LATEST:="0"}
: ${RETRY:=3}
: ${NO_CACHE:=""}
Expand Down Expand Up @@ -249,6 +250,10 @@ do
BUILD_HPCTOOLKIT="1"
reset-last
;;
"--build-x11vnc")
BUILD_X11VNC="1"
reset-last
;;
"--install-grafana")
INSTALL_GRAFANA="1"
reset-last
Expand Down Expand Up @@ -353,6 +358,7 @@ do
--build-arg BUILD_SCOREP=${BUILD_SCOREP} \
--build-arg BUILD_MPI4PY=${BUILD_MPI4PY} \
--build-arg BUILD_HPCTOOLKIT=${BUILD_HPCTOOLKIT} \
--build-arg BUILD_X11VNC=${BUILD_X11VNC} \
--build-arg USE_CACHED_APPS=${USE_CACHED_APPS} \
-t ${DOCKER_USER}/training:release-base-${DISTRO}-${DISTRO_VERSION}-rocm-${ROCM_VERSION} \
-t training \
Expand Down
10 changes: 10 additions & 0 deletions extras/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ARG BUILD_PYTORCH
ARG BUILD_CUPY
ARG BUILD_KOKKOS
ARG BUILD_JAX
ARG BUILD_X11VNC
ARG USE_CACHED_APPS
ARG AMDGPU_GFXMODEL=gfx90a
ARG PYTHON_VERSIONS
Expand Down Expand Up @@ -158,6 +159,15 @@ RUN /tmp/pytorch_setup.sh --build-pytorch ${BUILD_PYTORCH} --rocm-version ${ROCM
RUN echo "At end of pytorch install" && cd /app && ls -l && cd /tmp && ls -l && cd && ls -l
WORKDIR /app

#
# Install VNC
#
EXPOSE 5900
COPY extras/sources/scripts/x11vnc_setup.sh /tmp/x11vnc_setup.sh

RUN chmod u+x /tmp/x11vnc_setup.sh && \
/tmp/x11vnc_setup.sh --build-x11vnc ${BUILD_X11VNC} ; rm /tmp/x11vnc_setup.sh

#
# Install any additional apps or libs that are needed
#
Expand Down
4 changes: 4 additions & 0 deletions extras/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ echo "starting ssh server and waiting for ssh logins...."

/usr/sbin/sshd -D

#HAVE_X11VNC=`which x11vnc |wc -l`
#if [ "${HAVE_X11VNC}" == "1" ] then
# x11vnc -display :0 -rfbport 5900 -xkb -repeat -skip_dups -forever -shared -rfbauth "AAA"invoke-rc.d: could not determine current runlevel
#fi
75 changes: 75 additions & 0 deletions extras/sources/scripts/x11vnc_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

# Variables controlling setup process
BUILD_X11VNC=0

SUDO="sudo"
DEB_FRONTEND="DEBIAN_FRONTEND=noninteractive"

if [ -f /.singularity.d/Singularity ]; then
SUDO=""
DEB_FRONTEND=""
fi

usage()
{
echo "Usage:"
echo " --build-x11vnc [ BUILD_X11VNC ] default 0-no"
echo " --help: this usage information"
exit 1
}

send-error()
{
usage
echo -e "\nError: ${@}"
exit 1
}

reset-last()
{
last() { send-error "Unsupported argument :: ${1}"; }
}


n=0
while [[ $# -gt 0 ]]
do
case "${1}" in
"--build-x11vnc")
shift
BUILD_X11VNC=${1}
reset-last
;;
"--help")
usage
;;
"--*")
send-error "Unsupported argument at position $((${n} + 1)) :: ${1}"
;;
*)
last ${1}
;;
esac
n=$((${n} + 1))
shift
done

${SUDO} apt-get update
${SUDO} ${DEB_FRONTEND} apt-get install -y x11vnc xvfb

cat <<-EOF | ${SUDO} tee /usr/bin/startvncserver.sh
#!/bin/bash
if [ ! -f $HOME/.vnc/passwd ]; then
x11vnc -storepasswd
fi
/usr/bin/x11vnc -display :0 -auth $HOME/.Xauthority -rfbauth $HOME/.vnc/passwd -rfbport 5900 -forever -loop -noxdamage -repeat -shared -capslock -nomodtweak -create -auth guess &
EOF
${SUDO} chmod 755 /usr/bin/startvncserver.sh


cat <<-EOF | ${SUDO} tee /usr/bin/stopvncserver.sh
#!/bin/bash
killall x11vnc
EOF
${SUDO} chmod 755 /usr/bin/stopvncserver.sh

0 comments on commit b742888

Please sign in to comment.