diff --git a/dockerfile-kasm-core b/dockerfile-kasm-core index 364500c..e844be7 100644 --- a/dockerfile-kasm-core +++ b/dockerfile-kasm-core @@ -106,6 +106,10 @@ RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPT COPY ./src/ubuntu/install/gamepad $INST_SCRIPTS/gamepad/ RUN bash $INST_SCRIPTS/gamepad/install_gamepad.sh && rm -rf $INST_SCRIPTS/gamepad/ +### Install Webcam Service +COPY ./src/ubuntu/install/webcam $INST_SCRIPTS/webcam/ +RUN bash $INST_SCRIPTS/webcam/install_webcam.sh && rm -rf $INST_SCRIPTS/webcam/ + ### Install custom cursors COPY ./src/ubuntu/install/cursors $INST_SCRIPTS/cursors/ RUN bash $INST_SCRIPTS/cursors/install_cursors.sh && rm -rf $INST_SCRIPTS/cursors/ @@ -163,6 +167,7 @@ RUN touch $STARTUPDIR/wm.log \ && chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \ && chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \ && chmod 755 $STARTUPDIR/gamepad/kasm_gamepad_server \ + && chmod 755 $STARTUPDIR/webcam/kasm_webcam_server \ && chmod 755 $STARTUPDIR/generate_container_user \ && chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \ && rm -rf $STARTUPDIR/install \ diff --git a/dockerfile-kasm-core-alpine b/dockerfile-kasm-core-alpine index 42d1bf0..ce979b6 100644 --- a/dockerfile-kasm-core-alpine +++ b/dockerfile-kasm-core-alpine @@ -109,6 +109,10 @@ RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPT COPY ./src/ubuntu/install/gamepad $INST_SCRIPTS/gamepad/ RUN bash $INST_SCRIPTS/gamepad/install_gamepad.sh && rm -rf $INST_SCRIPTS/gamepad/ +### Install Webcam Service +COPY ./src/ubuntu/install/webcam $INST_SCRIPTS/webcam/ +RUN bash $INST_SCRIPTS/webcam/install_webcam.sh && rm -rf $INST_SCRIPTS/webcam/ + ### Copy built Squid COPY --from=squid_builder /usr/local/squid /usr/local/squid @@ -161,6 +165,7 @@ RUN touch $STARTUPDIR/wm.log \ && chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \ && chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \ && chmod 755 $STARTUPDIR/gamepad/kasm_gamepad_server \ + && chmod 755 $STARTUPDIR/webcam/kasm_webcam_server \ && chmod 755 $STARTUPDIR/generate_container_user \ && chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \ && rm -rf $STARTUPDIR/install \ diff --git a/dockerfile-kasm-core-centos b/dockerfile-kasm-core-centos index 6124774..3912099 100644 --- a/dockerfile-kasm-core-centos +++ b/dockerfile-kasm-core-centos @@ -111,6 +111,10 @@ RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPT COPY ./src/ubuntu/install/gamepad $INST_SCRIPTS/gamepad/ RUN bash $INST_SCRIPTS/gamepad/install_gamepad.sh && rm -rf $INST_SCRIPTS/gamepad/ +### Install Webcam Service +COPY ./src/ubuntu/install/webcam $INST_SCRIPTS/webcam/ +RUN bash $INST_SCRIPTS/webcam/install_webcam.sh && rm -rf $INST_SCRIPTS/webcam/ + ### Copy built Squid COPY --from=squid_builder /usr/local/squid /usr/local/squid @@ -163,6 +167,7 @@ RUN touch $STARTUPDIR/wm.log \ && chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \ && chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \ && chmod 755 $STARTUPDIR/gamepad/kasm_gamepad_server \ + && chmod 755 $STARTUPDIR/webcam/kasm_webcam_server \ && chmod 755 $STARTUPDIR/generate_container_user \ && chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \ && rm -rf $STARTUPDIR/install \ diff --git a/dockerfile-kasm-core-fedora b/dockerfile-kasm-core-fedora index 28b0f03..88459aa 100644 --- a/dockerfile-kasm-core-fedora +++ b/dockerfile-kasm-core-fedora @@ -115,6 +115,10 @@ RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPT COPY ./src/ubuntu/install/gamepad $INST_SCRIPTS/gamepad/ RUN bash $INST_SCRIPTS/gamepad/install_gamepad.sh && rm -rf $INST_SCRIPTS/gamepad/ +### Install Webcam Service +COPY ./src/ubuntu/install/webcam $INST_SCRIPTS/webcam/ +RUN bash $INST_SCRIPTS/webcam/install_webcam.sh && rm -rf $INST_SCRIPTS/webcam/ + ### Copy built Squid COPY --from=squid_builder /usr/local/squid /usr/local/squid @@ -167,6 +171,7 @@ RUN touch $STARTUPDIR/wm.log \ && chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \ && chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \ && chmod 755 $STARTUPDIR/gamepad/kasm_gamepad_server \ + && chmod 755 $STARTUPDIR/webcam/kasm_webcam_server \ && chmod 755 $STARTUPDIR/generate_container_user \ && chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \ && rm -rf $STARTUPDIR/install \ diff --git a/dockerfile-kasm-core-oracle b/dockerfile-kasm-core-oracle index a410361..ed25663 100644 --- a/dockerfile-kasm-core-oracle +++ b/dockerfile-kasm-core-oracle @@ -129,6 +129,10 @@ RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPT COPY ./src/ubuntu/install/gamepad $INST_SCRIPTS/gamepad/ RUN bash $INST_SCRIPTS/gamepad/install_gamepad.sh && rm -rf $INST_SCRIPTS/gamepad/ +### Install Webcam Service +COPY ./src/ubuntu/install/webcam $INST_SCRIPTS/webcam/ +RUN bash $INST_SCRIPTS/webcam/install_webcam.sh && rm -rf $INST_SCRIPTS/webcam/ + ### Copy built Squid COPY --from=squid_builder /usr/local/squid /usr/local/squid @@ -181,6 +185,7 @@ RUN touch $STARTUPDIR/wm.log \ && chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \ && chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \ && chmod 755 $STARTUPDIR/gamepad/kasm_gamepad_server \ + && chmod 755 $STARTUPDIR/webcam/kasm_webcam_server \ && chmod 755 $STARTUPDIR/generate_container_user \ && chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \ && rm -rf $STARTUPDIR/install \ diff --git a/dockerfile-kasm-core-suse b/dockerfile-kasm-core-suse index dce4449..1d63f15 100644 --- a/dockerfile-kasm-core-suse +++ b/dockerfile-kasm-core-suse @@ -108,6 +108,10 @@ RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPT COPY ./src/ubuntu/install/gamepad $INST_SCRIPTS/gamepad/ RUN bash $INST_SCRIPTS/gamepad/install_gamepad.sh && rm -rf $INST_SCRIPTS/gamepad/ +### Install Webcam Service +COPY ./src/ubuntu/install/webcam $INST_SCRIPTS/webcam/ +RUN bash $INST_SCRIPTS/webcam/install_webcam.sh && rm -rf $INST_SCRIPTS/webcam/ + ### Copy built Squid COPY --from=squid_builder /usr/local/squid /usr/local/squid @@ -160,6 +164,7 @@ RUN touch $STARTUPDIR/wm.log \ && chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \ && chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \ && chmod 755 $STARTUPDIR/gamepad/kasm_gamepad_server \ + && chmod 755 $STARTUPDIR/webcam/kasm_webcam_server \ && chmod 755 $STARTUPDIR/generate_container_user \ && chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \ && rm -rf $STARTUPDIR/install \ diff --git a/src/common/startup_scripts/vnc_startup.sh b/src/common/startup_scripts/vnc_startup.sh index 14b80b4..0d23316 100755 --- a/src/common/startup_scripts/vnc_startup.sh +++ b/src/common/startup_scripts/vnc_startup.sh @@ -182,6 +182,20 @@ function start_gamepad (){ fi } +function start_webcam (){ + if [[ ${KASM_SVC_WEBCAM:-1} == 1 ]] && [[ -e /dev/video0 ]]; then + echo 'Starting webcam server' + $STARTUPDIR/webcam/kasm_webcam_server --debug --port 4905 --ssl --cert ${HOME}/.vnc/self.pem --certkey ${HOME}/.vnc/self.pem & + + KASM_PROCS['kasm_webcam']=$! + + if [[ $DEBUG == true ]]; then + echo -e "\n------------------ Started Webcam Websocket ----------------------------" + echo "Kasm Webcam PID: ${KASM_PROCS['kasm_webcam']}"; + fi + fi +} + function custom_startup (){ custom_startup_script=/dockerstartup/custom_startup.sh if [ -f "$custom_startup_script" ]; then @@ -247,6 +261,7 @@ start_audio_out start_audio_in start_upload start_gamepad +start_webcam STARTUP_COMPLETE=1 @@ -307,11 +322,16 @@ do # TODO: This will only work if both processes are killed, requires more work start_upload ;; - kasm_gamepad) + kasm_gamepad) echo "Gamepad Service Failed" # TODO: Needs work in python project to support auto restart # start_gamepad ;; + kasm_webcam) + echo "Webcam Service Failed" + # TODO: Needs work in python project to support auto restart + start_webcam + ;; custom_script) echo "The custom startup script exited." # custom startup scripts track the target process on their own, they should not exit diff --git a/src/ubuntu/install/webcam/install_webcam.sh b/src/ubuntu/install/webcam/install_webcam.sh new file mode 100644 index 0000000..2dd1487 --- /dev/null +++ b/src/ubuntu/install/webcam/install_webcam.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +### every exit != 0 fails the script +set -e + +if [ "${DISTRO}" == "oracle7" ]; then + DISTRO=centos +elif [ "${DISTRO}" == "oracle8" ]; then + DISTRO=oracle +fi + +COMMIT_ID="fa0008ce9742287b87bbc2ad845f2bdf018bd250" +BRANCH="develop" +COMMIT_ID_SHORT=$(echo "${COMMIT_ID}" | cut -c1-6) + +ARCH=$(arch | sed 's/aarch64/arm64/g' | sed 's/x86_64/amd64/g') + +mkdir -p $STARTUPDIR/webcam +wget -qO- https://kasmweb-build-artifacts.s3.amazonaws.com/kasm_webcam_server/${COMMIT_ID}/kasm_webcam_server_${ARCH}_${BRANCH}.${COMMIT_ID_SHORT}.tar.gz | tar -xvz -C $STARTUPDIR/webcam/ +