diff --git a/BasicMetaDesktop/run.sh b/BasicMetaDesktop/run.sh index 185fdd3010d2736db49b841a8251b529bf8a1561..8ad8988ff12939a92101317496fa85efe8bd079b 100755 --- a/BasicMetaDesktop/run.sh +++ b/BasicMetaDesktop/run.sh @@ -1,2 +1,2 @@ #!/bin/bash -docker run -v$PWD/:/data -p5900:5900 -p8590:8590 -it basicmetadesktop +docker run -v$PWD/:/data -p8590:8590 -it basicmetadesktop diff --git a/DevMetaDesktop/run.sh b/DevMetaDesktop/run.sh index 4cfc7c18263e21c31349887133f68cbd4e10a88b..5b49bde78fe1ad282eaf1972ff9dc3d6731cfe10 100755 --- a/DevMetaDesktop/run.sh +++ b/DevMetaDesktop/run.sh @@ -1,2 +1,2 @@ #!/bin/bash -docker run -v$PWD/:/data -p5900:5900 -p8590:8590 -it devmetadesktop +docker run -v$PWD/:/data -p8590:8590 -it devmetadesktop diff --git a/MinimalMetaDesktop/Dockerfile b/MinimalMetaDesktop/Dockerfile index e4e82a21d92d312f1ad45d7bc3e81451c43fa2ee..2fc4ab5e4fe6812cc80e98d79143e714d111ec53 100644 --- a/MinimalMetaDesktop/Dockerfile +++ b/MinimalMetaDesktop/Dockerfile @@ -49,45 +49,46 @@ COPY files/supervisord.conf /etc/supervisor/ RUN apt-get install xvfb xterm -y # Install base packages for VNC server and headless desktop (2) -RUN cd /opt && wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.8.0.x86_64.tar.gz -O tigervnc-1.8.0.x86_64.tar.gz \ - && tar -zxvf tigervnc-1.8.0.x86_64.tar.gz \ - && mv tigervnc-1.8.0.x86_64 tigervnc +#RUN cd /opt && wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.8.0.x86_64.tar.gz -O tigervnc-1.8.0.x86_64.tar.gz \ +# && tar -zxvf tigervnc-1.8.0.x86_64.tar.gz \ +# && mv tigervnc-1.8.0.x86_64 tigervnc # Supervisord configuration -COPY files/supervisord_vnc.conf /etc/supervisor/conf.d/ -COPY files/run_vnc.sh /etc/supervisor/conf.d/ -COPY files/run_novnc.sh /etc/supervisor/conf.d/ -RUN chmod 755 /etc/supervisor/conf.d/run_vnc.sh -RUN chmod 755 /etc/supervisor/conf.d/run_novnc.sh - -# Web VNC (noVNC) v0.6.1. -# NOTE: this is a custom version from Doro Wu (fcwu.tw@gmail.com). -# TODO: Check differences and maybe move to 0.6.2 -COPY files/noVNC.tar.gz /usr/lib/ -RUN cd /usr/lib/ && tar -zxvf noVNC.tar.gz -COPY files/index.html /usr/lib/noVNC - +COPY files/supervisord_kasm.conf /etc/supervisor/conf.d/ +COPY files/run_kasm.sh /etc/supervisor/conf.d/ +RUN chmod 755 /etc/supervisor/conf.d/run_kasm.sh + +# Kasm VNC (modded by gtaffoni to use a socket named by an env var) +COPY files/kasmvnc-Linux-x86_64-0.9.tar.gz /tmp +RUN sudo tar xz --strip 1 -C / -f /tmp/kasmvnc-Linux-x86_64-0.9.tar.gz && rm /tmp/kasmvnc-Linux-x86_64-0.9.tar.gz +RUN mkdir /usr/local/share/kasmvnc/certs +RUN chown metauser:metauser /usr/local/share/kasmvnc/certs +COPY files/index.html /usr/local/share/kasmvnc/www/ + +# Other utilities RUN apt-get install -y net-tools -# Supervisord configuration -COPY files/supervisord_novnc.conf /etc/supervisor/conf.d/ - # X environment setup/startup RUN apt-get install fluxbox -y -COPY files/xstartup /opt/tigervnc/ -RUN chmod 755 /opt/tigervnc/xstartup +RUN mkdir -p /metauser_home_vanilla/.vnc +COPY files/config /metauser_home_vanilla/.vnc +COPY files/xstartup /metauser_home_vanilla/.vnc +RUN chmod 755 /metauser_home_vanilla/.vnc/xstartup +RUN chown -R metauser:metauser /metauser_home_vanilla/.vnc # Prepare for logs -RUN mkdir /home/metauser/.logs && chown metauser:metauser /home/metauser/.logs +RUN mkdir /metauser_home_vanilla/.logs && chown metauser:metauser /metauser_home_vanilla/.logs # Rename metauser home folder as a "vanilla" home folder -RUN mv /home/metauser /metauser_home_vanilla +#RUN mv /home/metauser /metauser_home_vanilla # Add fluxbox customisations COPY files/dot_fluxbox /metauser_home_vanilla/.fluxbox RUN chown -R metauser:metauser /metauser_home_vanilla/.fluxbox COPY files/background.jpg /usr/share/images/fluxbox/background.jpg + + # Give write access to anyone to the home folder so the entrypoint will be able # to copy over the /home/matauser_vanilla into /home/metauser (for Singularity) RUN chmod 777 /home diff --git a/MinimalMetaDesktop/files/config b/MinimalMetaDesktop/files/config new file mode 100644 index 0000000000000000000000000000000000000000..b3665bf01cbe8e3a2f244ec8da3b520045b65355 --- /dev/null +++ b/MinimalMetaDesktop/files/config @@ -0,0 +1,10 @@ +## Supported server options to pass to vncserver upon invocation can be listed +## in this file. See the following manpages for more: vncserver(1) Xvnc(1). +## Several common ones are shown below. Uncomment and modify to your liking. +## +# securitytypes=vncauth,tlsvnc +# desktop=sandbox +# geometry=2000x1200 +# localhost +# alwaysshared +username=metauser diff --git a/MinimalMetaDesktop/files/entrypoint.sh b/MinimalMetaDesktop/files/entrypoint.sh index fabb3eb723509c77d0613b28060effdcff607dad..6bf8ad4eb87ab41d4ae2384aa2f8845cb8c84c6b 100644 --- a/MinimalMetaDesktop/files/entrypoint.sh +++ b/MinimalMetaDesktop/files/entrypoint.sh @@ -60,22 +60,35 @@ else echo "export $env_var" >> /tmp/env.sh fi done + #--------------------- # Password #--------------------- - - if [ "x$AUTH_PASS" != "x" ]; then - echo "[INFO] Setting up VNC password..." - mkdir -p /home/metauser/.vnc - /opt/tigervnc/usr/bin/vncpasswd -f <<< $AUTH_PASS > /home/metauser/.vnc/passwd - chmod 600 /home/metauser/.vnc/passwd - export VNC_AUTH=True - else - echo "[INFO] Not setting up any VNC password" - - fi - + + if [ "x$AUTH_PASS" != "x" ]; then + echo "[INFO] Setting up VNC password..." + else + echo "[INFO] Setting up default VNC password (metapassword)" + AUTH_PASS=metapass + fi + /usr/local/bin/kasmvncpasswd -f <<< $AUTH_PASS > /home/metauser/.kasmpasswd + chmod 600 /home/metauser/.kasmpasswd + export VNC_AUTH=True + + + #--------------------- + # User + #--------------------- + + if [ "x$AUTH_USER" != "x" ]; then + echo "[INFO] Setting up VNC user..." + sed -i -e "s/username=metauser/username=$AUTH_USER/" /home/metauser/.vnc/config + else + echo "[INFO] Setting up default VNC user (metauser)" + fi + + echo "[INFO] Setting new prompt @$CONTAINER_NAME container" echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /home/metauser/.bashrc diff --git a/MinimalMetaDesktop/files/index.html b/MinimalMetaDesktop/files/index.html index 6a6c57d819e940020afaaef0023fa1a788867147..e663397e8792c2dde3868ab5014d6a4e562628d9 100644 --- a/MinimalMetaDesktop/files/index.html +++ b/MinimalMetaDesktop/files/index.html @@ -2,11 +2,11 @@ <head> <script type="text/javascript"> function redirecter(){ - window.location = "./vnc.html?autoconnect=true&resize=remote" + window.location = "./vnc.html" } </script> </head> <body onLoad="redirecter()"> -Access VNC: click <a href="./vnc.html?autoconnect=true&resize=remote">here</a>. +Access VNC: click <a href="./vnc.html">here</a>. </body> </html> \ No newline at end of file diff --git a/MinimalMetaDesktop/files/kasmvnc-Linux-x86_64-0.9.tar.gz b/MinimalMetaDesktop/files/kasmvnc-Linux-x86_64-0.9.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..1bc58413497aa1d9bdd071508d843ab0bf9268af Binary files /dev/null and b/MinimalMetaDesktop/files/kasmvnc-Linux-x86_64-0.9.tar.gz differ diff --git a/MinimalMetaDesktop/files/noVNC.tar.gz b/MinimalMetaDesktop/files/noVNC.tar.gz deleted file mode 100644 index a531bed617c54af4826c7afd76192bc2736100ba..0000000000000000000000000000000000000000 Binary files a/MinimalMetaDesktop/files/noVNC.tar.gz and /dev/null differ diff --git a/MinimalMetaDesktop/files/run_kasm.sh b/MinimalMetaDesktop/files/run_kasm.sh new file mode 100755 index 0000000000000000000000000000000000000000..cd69c59df8c44c306da6948e693272e1ddf87f49 --- /dev/null +++ b/MinimalMetaDesktop/files/run_kasm.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Exec KasmVNC server + +if [ "x$BASE_PORT" == "x" ]; then + BASE_PORT=8590 + DESKTOP_NUMBER=1 +else + DESKTOP_NUMBER=$(($BASE_PORT-5900+1)) +fi + +if [ "x$KASMSOCK" == "xTrue" ]; then + export SOCKET_PORT=$(( $RANDOM % 50 + 1 )) +fi + +if [ "x$VNC_AUTH" == "xTrue" ]; then + echo "[INFO] Setting new certificate for VNC" + openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /home/metauser/.vnc/self.pem -out /home/metauser/.vnc/self.pem -subj "/C=IT/ST=None/L=None/O=INAF/OU=OATs/CN=kasm/emailAddress=none@none.none" + /usr/local/bin/vncserver :$DESKTOP_NUMBER -depth 24 -geometry 1280x1050 -websocketPort $BASE_PORT -cert /home/metauser/.vnc/self.pem -sslOnly -FrameRate=24 -interface 0.0.0.0 +else + /usr/local/bin/vncserver :$DESKTOP_NUMBER -depth 24 -geometry 1280x1050 -websocketPort $BASE_PORT -FrameRate=24 -interface 0.0.0.0 +fi + +# Check it is running. If it is not, exit +while true +do + + #PSOUT=$(ps -ef | grep /usr/local/bin/Xvnc | grep SecurityTypes) + PSOUT=$(ps -ef | grep /usr/local/bin/Xvnc) + + if [[ "x$PSOUT" == "x" ]] ; then + exit 1 + fi + + # Sleep other 10 secs before re-checking + sleep 10 + +done diff --git a/MinimalMetaDesktop/files/run_novnc.sh b/MinimalMetaDesktop/files/run_novnc.sh deleted file mode 100755 index 53198782b7aea92d8cd8c5181a5fefac7fa91b22..0000000000000000000000000000000000000000 --- a/MinimalMetaDesktop/files/run_novnc.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Exec TigerVNC server - -if [ "x$BASE_PORT" == "x" ]; then - /usr/lib/noVNC/utils/launch.sh --listen 8590 - echo "Running noVNC on port 8590" -else - /usr/lib/noVNC/utils/launch.sh --listen $BASE_PORT --vnc localhost:$(($BASE_PORT+1)) - echo "Running noVNC on port $BASE_PORT and connecting to VNC on port $(($BASE_PORT+1))" - -fi diff --git a/MinimalMetaDesktop/files/run_vnc.sh b/MinimalMetaDesktop/files/run_vnc.sh deleted file mode 100755 index ac7daebd51232559545e9bdcf71dbd5e79140cb6..0000000000000000000000000000000000000000 --- a/MinimalMetaDesktop/files/run_vnc.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Exec TigerVNC server - -if [ "x$BASE_PORT" == "x" ]; then - DESKTOP_NUMBER=0 -else - DESKTOP_NUMBER=$(($BASE_PORT-5900+1)) -fi - -if [ "x$VNC_AUTH" == "xTrue" ]; then - /opt/tigervnc/usr/bin/vncserver :$DESKTOP_NUMBER -SecurityTypes vncauth,tlsvnc -xstartup /opt/tigervnc/xstartup -else - /opt/tigervnc/usr/bin/vncserver :$DESKTOP_NUMBER -SecurityTypes None -xstartup /opt/tigervnc/xstartup -fi - - -# Check it is running. If it is not, exit -while true -do - - PSOUT=$(ps -ef | grep /opt/tigervnc/usr/bin/Xvnc | grep SecurityTypes) - - if [[ "x$PSOUT" == "x" ]] ; then - exit 1 - fi - - # Sleep other 10 secs before re-checking - sleep 10 - -done diff --git a/MinimalMetaDesktop/files/supervisord_vnc.conf b/MinimalMetaDesktop/files/supervisord_kasm.conf similarity index 81% rename from MinimalMetaDesktop/files/supervisord_vnc.conf rename to MinimalMetaDesktop/files/supervisord_kasm.conf index 42aa37b339d52d8bddfd8a974c70446e51cfc786..9ff0a85427876c4675630a01160afd6d2f38f26c 100644 --- a/MinimalMetaDesktop/files/supervisord_vnc.conf +++ b/MinimalMetaDesktop/files/supervisord_kasm.conf @@ -1,18 +1,18 @@ ;======================================= -; VNC service +; KasmVNC service ;======================================= -[program:vnc] +[program:kasmvnc] ; General directory = / -command = /etc/supervisor/conf.d/run_vnc.sh +command = /etc/supervisor/conf.d/run_kasm.sh numprocs = 1 autostart = true autorestart = true startsecs = 10 stopwaitsecs = 30 -process_name = vnc +process_name = kasmvnc ; Standard out / error stdout_logfile = /home/metauser/.logs/%(program_name)s.log diff --git a/MinimalMetaDesktop/files/supervisord_novnc.conf b/MinimalMetaDesktop/files/supervisord_novnc.conf deleted file mode 100644 index 2a4e685fe1aead80d61cd4a5b48b6c981d8348f1..0000000000000000000000000000000000000000 --- a/MinimalMetaDesktop/files/supervisord_novnc.conf +++ /dev/null @@ -1,23 +0,0 @@ -;======================================= -; noVNC service -;======================================= - -[program:novnc] - -; General -directory = /usr/lib/noVNC/ -command = /etc/supervisor/conf.d/run_novnc.sh -numprocs = 1 -autostart = true -autorestart = true -startsecs = 10 -stopwaitsecs = 30 -process_name = novnc - -; Standard out / error -stdout_logfile = /home/metauser/.logs/%(program_name)s.log -stdout_logfile_maxbytes = 5MB -stdout_logfile_backups = 10 -stderr_logfile = /home/metauser/.logs/%(program_name)s.log -stderr_logfile_maxbytes = 5MB -stderr_logfile_backups = 10 diff --git a/MinimalMetaDesktop/run.sh b/MinimalMetaDesktop/run.sh index 5ec2cd93a2fc8abd5b307c970127ea6296332ac3..471393581be1fd4fa3b4f915adc95454cbba08e1 100755 --- a/MinimalMetaDesktop/run.sh +++ b/MinimalMetaDesktop/run.sh @@ -1,2 +1,2 @@ #!/bin/bash -docker run -v$PWD/:/data -p5900:5900 -p8590:8590 -it minimalmetadesktop +docker run -v$PWD/:/data -p8590:8590 -it minimalmetadesktop