Skip to content
Snippets Groups Projects
Commit 04c183da authored by bta's avatar bta
Browse files

Add a screendump service.

parent a180927f
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Step by step output as the script runs, until we are confident enough
set -x
DATE=`date +%Y-%m-%dT%H:%M:%S`
BASEDIR=/local/sdump
start() {
# Prepare the output directory
mkdir -p "${BASEDIR}"
chmod 700 "${BASEDIR}"
chown -h sdump:sdump "${BASEDIR}"
# Ask the system to clean old files
if [ ! -f /etc/tmpfiles.d/sdump.conf ]; then
echo 'q /local/sdump 700 sdump sdump 60d' > /etc/tmpfiles.d/sdump.conf
fi
# Wait for the .Xauthority file
while [ ! -f "/local/${ESAME_USER}/.Xauthority" ]; do
sleep 5
done
# Wait for the new token
sleep 10
# Copy the X11 token
cp "/local/${ESAME_USER}/.Xauthority" ~sdump/
chown -h sdump:sdump ~sdump/.Xauthority
# Fake it 'till you make it
ln -s /usr/bin/ffmpeg ~sdump/[sysdump]
# Hide processes
mount /proc/ -o remount,hidepid=2
# Start the screen dump
#CMD="ffmpeg -framerate 1 -f x11grab -i :0.0 -vcodec libx265 -crf 28 \"${BASEDIR}/${DATE}.mkv\""
#CMD="ffmpeg -framerate 1 -f x11grab -i :0.0 -vcodec libx265 -crf 28 -vf \"drawtext='text=%{localtime\:%X}:fontsize=32:fontcolor=red'\" \"${BASEDIR}/${DATE}.mkv\""
CMD="PATH=\"$PATH:.\" [sysdump] -framerate 1 -f x11grab -i :0.0 -vcodec libx265 -crf 28 -vf \"drawtext='text=%{localtime\:%X}:fontsize=32:fontcolor=red'\" \"${BASEDIR}/${DATE}.mkv\""
su - sdump -c "${CMD}"
}
stop() {
# Send a SIGTERM to ffmpeg to stop the screen dump
pkill -u sdump ffmpeg
# Give ffmpeg time to finalize the file
sleep 10
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
*)
echo "Usage: $0 { start | stop | restart }";
exit 1;
;;
esac
exit 0
......@@ -9,13 +9,14 @@ ESAME_DIR=/opt/esame
BIN_FILES=(
"desktop-wallpaper" "esamesync-esame.sh" "firefox-home" "get-config" "iptables-rules" "lightdm-autologin"
"kioskmode" "mk-homedir" "nfs" "usb" "virtualbox" "rabbitmq-client.py"
"screendump"
)
SYSTEMD_FILES=(
"esame-desktop-wallpaper.service" "esame-firefox-home.service" "esame-get-config-boot.service" "esame-get-config.service" "esame-iptables-rules.service"
"esame-dm-autologin.service" "esame-kioskmode.service" "esame-mk-homedir.service" "esame-nfs.service" "esame-usb.service" "esame-virtualbox.service"
"esamesync-esame.service" "esame-get-config.timer" "esame-configurator.target" "esame.target" "esamekiosk.target" "esameshow.target" "esame-multi-user.target"
"esame-rabbitmq-client.service"
"esame-rabbitmq-client.service" "esame-screendump.service"
)
USBGUARD_OVERRIDE_FILES=(
......
[Unit]
Description=Dump the screen
After=esame-mk-homedir.service esame-desktop-wallpaper.service esame-firefox-home.service esame-virtualbox.service
[Service]
Type=exec
EnvironmentFile=-/local/esame-machine.conf
ExecStart=/usr/libexec/labmanager/screendump start
ExecStop=/usr/libexec/labmanager/screendump stop
TimeoutStopSec=120
[Install]
WantedBy=esame.target esamekiosk.target esameshow.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment