KASM-4083 add webcam support to core images and block starting if video device does not exist

This commit is contained in:
ryan.kuba 2023-03-24 12:12:03 -07:00
parent 8748cadc0d
commit 1f48d438df
No known key found for this signature in database
8 changed files with 70 additions and 1 deletions

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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

View File

@ -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/