diff --git a/dockerfile-kasm-core b/dockerfile-kasm-core index 68f39a0..1c4620c 100644 --- a/dockerfile-kasm-core +++ b/dockerfile-kasm-core @@ -43,7 +43,8 @@ ENV DISPLAY=:1 \ START_PULSEAUDIO=$START_PULSEAUDIO \ LANG=$LANG \ LANGUAGE=$LANGUAGE \ - LC_ALL=$LC_ALL + LC_ALL=$LC_ALL \ + KASMVNC_AUTO_RECOVER=true EXPOSE $VNC_PORT \ $NO_VNC_PORT \ @@ -70,8 +71,6 @@ ADD /src/common/resources/images/icon_ubuntu.png /usr/share/extra/icons/icon_ubu ADD /src/common/resources/images/icon_ubuntu.png /usr/share/extra/icons/icon_default.png ADD /src/common/resources/images/icon_kasm.png /usr/share/extra/icons/icon_kasm.png -ADD ./src/common/xfce/window_manager_startup.sh $STARTUPDIR - ### Install kasm_vnc dependencies and binaries COPY ./src/ubuntu/install/kasm_vnc $INST_SCRIPTS/kasm_vnc/ RUN bash $INST_SCRIPTS/kasm_vnc/install_kasm_vnc.sh && rm -rf $INST_SCRIPTS/kasm_vnc/ diff --git a/dockerfile-kasm-core-centos b/dockerfile-kasm-core-centos index 7e7a862..1dc9a3e 100644 --- a/dockerfile-kasm-core-centos +++ b/dockerfile-kasm-core-centos @@ -54,7 +54,8 @@ ENV DISPLAY=:1 \ LANG=$LANG \ LANGUAGE=$LANGUAGE \ LC_ALL=$LC_ALL \ - SINGLE_APPLICATION=0 + SINGLE_APPLICATION=0 \ + KASMVNC_AUTO_RECOVER=true EXPOSE $VNC_PORT \ $NO_VNC_PORT \ @@ -81,7 +82,6 @@ RUN bash $INST_SCRIPTS/xfce/install_xfce_ui.sh && rm -rf $INST_SCRIPTS/xfce/ COPY ./src/$DISTRO/xfce/.config/ $HOME/.config/ COPY /src/common/resources/images/bg_kasm.png /usr/share/backgrounds/bg_kasm.png COPY /src/common/resources/images/$BG_IMG /usr/share/backgrounds/bg_default.png -COPY ./src/common/xfce/window_manager_startup.sh $STARTUPDIR ### Install kasm_vnc dependencies and binaries COPY ./src/ubuntu/install/kasm_vnc $INST_SCRIPTS/kasm_vnc/ diff --git a/dockerfile-kasm-core-nvidia b/dockerfile-kasm-core-nvidia index 828c575..d80eeb9 100644 --- a/dockerfile-kasm-core-nvidia +++ b/dockerfile-kasm-core-nvidia @@ -51,7 +51,8 @@ ENV DISPLAY=:1 \ START_PULSEAUDIO=$START_PULSEAUDIO \ LANG=$LANG \ LANGUAGE=$LANGUAGE \ - LC_ALL=$LC_ALL + LC_ALL=$LC_ALL \ + KASMVNC_AUTO_RECOVER=true EXPOSE $VNC_PORT \ $NO_VNC_PORT \ @@ -84,8 +85,6 @@ ADD /src/common/resources/images/icon_ubuntu.png /usr/share/extra/icons/icon_ubu ADD /src/common/resources/images/icon_ubuntu.png /usr/share/extra/icons/icon_default.png ADD /src/common/resources/images/icon_kasm.png /usr/share/extra/icons/icon_kasm.png -ADD ./src/common/xfce/window_manager_startup.sh $STARTUPDIR - ### Install kasm_vnc dependencies and binaries COPY ./src/ubuntu/install/kasm_vnc $INST_SCRIPTS/kasm_vnc/ RUN bash $INST_SCRIPTS/kasm_vnc/install_kasm_vnc.sh && rm -rf $INST_SCRIPTS/kasm_vnc/ diff --git a/src/common/startup_scripts/vnc_startup.sh b/src/common/startup_scripts/vnc_startup.sh index 03bc837..7bcbc91 100644 --- a/src/common/startup_scripts/vnc_startup.sh +++ b/src/common/startup_scripts/vnc_startup.sh @@ -73,8 +73,20 @@ function start_kasmvnc (){ } function start_window_manager (){ - echo -e "start window manager\n..." - $STARTUPDIR/window_manager_startup.sh #&> $STARTUPDIR/window_manager_startup.log + echo -e "\n------------------ Xfce4 window manager startup------------------" + + if [ "${START_XFCE4}" == "1" ] ; then + if [ -f /opt/VirtualGL/bin/vglrun ] && [ ! -z "${KASM_EGL_CARD}" ] && [ ! -z "${KASM_RENDERD}" ] && [ -O "${KASM_RENDERD}" ] && [ -O "${KASM_EGL_CARD}" ] ; then + echo "Starting XFCE with VirtualGL using EGL device ${KASM_EGL_CARD}" + DISPLAY=:1 /opt/VirtualGL/bin/vglrun -d "${KASM_EGL_CARD}" /usr/bin/startxfce4 --replace & + else + echo "Starting XFCE" + /usr/bin/startxfce4 --replace & + fi + KASM_PROCS['window_manager']=$! + else + echo "Skipping XFCE Startup" + fi } function start_audio_out_websocket (){ @@ -132,8 +144,7 @@ function start_audio_in (){ function start_upload (){ if [[ ${KASM_SVC_UPLOADS:-1} == 1 ]]; then echo 'Starting upload server' - cd $STARTUPDIR/upload_server/ - ./kasm_upload_server --ssl --auth-token "kasm_user:$VNC_PW" & + $STARTUPDIR/upload_server/kasm_upload_server --ssl --auth-token "kasm_user:$VNC_PW" & KASM_PROCS['upload_server']=$! @@ -144,6 +155,19 @@ function start_upload (){ fi } +function custom_startup (){ + custom_startup_script=/dockerstartup/custom_startup.sh + if [ -f "$custom_startup_script" ]; then + if [ ! -x "$custom_startup_script" ]; then + echo "${custom_startup_script}: not executable, exiting" + exit 1 + fi + + "$custom_startup_script" & + KASM_PROCS['custom_startup']=$! + fi +} + ############ END FUNCTION DECLARATIONS ########### if [[ $1 =~ -h|--help ]]; then @@ -209,15 +233,7 @@ KASMIP=$(hostname -i) echo "Kasm User ${KASM_USER}(${KASM_USER_ID}) started container id ${HOSTNAME} with local IP address ${KASMIP}" # start custom startup script -custom_startup_script=/dockerstartup/custom_startup.sh -if [ -f "$custom_startup_script" ]; then - if [ ! -x "$custom_startup_script" ]; then - echo "${custom_startup_script}: not executable, exiting" - exit 1 - fi - - "$custom_startup_script" & -fi +custom_startup # Monitor Kasm Services sleep 3 @@ -233,11 +249,17 @@ do case $process in kasmvnc) - echo "KasmVNC crashed, exiting container" - exit 1 - # TODO: Is there a way to restore gracefully, restarting the container may be the best here - #start_kasmvnc - #/dockerstartup/custom_startup.sh + if [ "$KASMVNC_AUTO_RECOVER" = true ] ; then + echo "KasmVNC crashed, restarting" + start_kasmvnc + else + echo "KasmVNC crashed, exiting container" + exit 1 + fi + ;; + window_manager) + echo "Window manager crashed, restarting" + start_window_manager ;; kasm_audio_out_websocket) echo "Restarting Audio Out Websocket Service" @@ -257,6 +279,11 @@ do # TODO: This will only work if both processes are killed, requires more work start_upload ;; + custom_script) + echo "The custom startup script exited." + # custom startup scripts track the target process on their own, they should not exit + custom_startup + ;; *) echo "Unknown Service: $process" ;; diff --git a/src/common/xfce/window_manager_startup.sh b/src/common/xfce/window_manager_startup.sh deleted file mode 100644 index 485c205..0000000 --- a/src/common/xfce/window_manager_startup.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e - -echo -e "\n------------------ Xfce4 window manager startup------------------" - -if [ "${START_XFCE4}" == "1" ] ; then - if [ -f /opt/VirtualGL/bin/vglrun ] && [ ! -z "${KASM_EGL_CARD}" ] && [ ! -z "${KASM_RENDERD}" ] && [ -O "${KASM_RENDERD}" ] && [ -O "${KASM_EGL_CARD}" ] ; then - echo "Starting XFCE with VirtualGL using EGL device ${KASM_EGL_CARD}" - DISPLAY=:1 /opt/VirtualGL/bin/vglrun -d "${KASM_EGL_CARD}" /usr/bin/startxfce4 --replace & - else - echo "Starting XFCE" - /usr/bin/startxfce4 --replace & - fi -else - echo "Skipping XFCE Startup" -fi