mirror of
https://github.com/kasmtech/workspaces-core-images.git
synced 2024-11-25 00:43:11 +01:00
KASM-5378 Abort session if the recording service is not running or was not started by the correct user
This commit is contained in:
parent
441bdc1865
commit
78c7096f27
@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
action=$1
|
||||
|
||||
pid=$(pgrep -f '^/dockerstartup/recorder/kasm_recorder_service')
|
||||
|
||||
case $action in
|
||||
"stop"|"pause")
|
||||
if [ -z "$pid" ]; then
|
||||
echo "No recording process found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
kill -s SIGINT $pid
|
||||
while [ ! -f "/tmp/kasm_recorder.ack" ]; do
|
||||
sleep 1
|
||||
done
|
||||
;;
|
||||
"resume")
|
||||
if [ ! -z "$pid" ]; then
|
||||
echo "Recording process already running."
|
||||
exit 0
|
||||
fi
|
||||
kill `pgrep -f "kasm_recorder_startup.sh"`
|
||||
/dockerstartup/kasm_recorder_startup.sh &
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {stop|pause|resume}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
mkdir -p /opt/kasm/recordings
|
||||
sudo chown kasm-recorder:kasm-recorder /opt/kasm/recordings
|
||||
sudo chmod 700 /opt/kasm/recordings
|
||||
|
||||
# wait until X display is avaiable and allow the recorder to connect to it
|
||||
while ! xhost +SI:localuser:kasm-recorder 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
rm -rf /tmp/kasm_recorder.ack
|
||||
|
||||
while [ ! -f "/tmp/kasm_recorder.ack" ]; do
|
||||
runuser -m kasm-recorder -c "$STARTUPDIR/recorder/kasm_recorder_service --debug 1 --directory /opt/kasm/recordings/ --log /tmp/recorder.log" || true
|
||||
sleep 1
|
||||
done
|
@ -313,6 +313,37 @@ function custom_startup (){
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_recorder_running () {
|
||||
kasm_recorder_process="/dockerstartup/recorder/kasm_recorder_service"
|
||||
|
||||
if [[ ${KASM_SVC_RECORDER:-1} != 1 ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
recorder_pid=$(pgrep -f "^$kasm_recorder_process") || true
|
||||
|
||||
if [[ -z $kasm_recorder_pid ]]; then
|
||||
if [[ -z $recorder_pid ]] && (( $SECONDS > 15 )); then
|
||||
echo "$kasm_recorder_process: not started, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
kasm_recorder_pid=$recorder_pid
|
||||
else
|
||||
if [[ -z $recorder_pid ]]; then
|
||||
echo "$kasm_recorder_process: not running, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
recorder_user=$(ps -p $recorder_pid -o user=)
|
||||
if [[ $recorder_user != "kasm-recorder" ]]; then
|
||||
echo "$kasm_recorder_process: not running as kasm-recorder, exiting"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
############ END FUNCTION DECLARATIONS ###########
|
||||
|
||||
if [[ $1 =~ -h|--help ]]; then
|
||||
@ -457,6 +488,9 @@ do
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
ensure_recorder_running
|
||||
|
||||
sleep 3
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user