Skip to content

Instantly share code, notes, and snippets.

@notfood
Last active February 16, 2020 01:40
Show Gist options
  • Save notfood/6fc39f7e16618fe91f8980d6c08a1b6f to your computer and use it in GitHub Desktop.
Save notfood/6fc39f7e16618fe91f8980d6c08a1b6f to your computer and use it in GitHub Desktop.
Makes a preview of recent archived sessions available
#!/bin/sh
export XDG_RUNTIME_DIR=/tmp/runtime-root
SESSIONS=/var/lib/drawpile/sessions
ARCHIVES=/var/lib/drawpile/archived
cp $SESSIONS/*.session $ARCHIVES 2>/dev/null
mv $SESSIONS/*.session.archived $ARCHIVES 2>/dev/null
for f in $(ls $SESSIONS/*.dprec.archived); do
/usr/local/bin/drawpile-cmd -platform offscreen -f jpeg -a -s 200x150 -S $f
mv $f $ARCHIVES
done
mv $SESSIONS/*.jpeg $ARCHIVES
rename -- .archived '' /var/lib/drawpile/archived/*.archived
#Ubuntu uses a different rename, the above can fail, replace with this one
#rename 's/\.archived$//' /var/lib/drawpile/archived/*.archived
[Unit]
Description=Drawpile archived sessions vacuum
[Service]
Type=oneshot
ExecStart=find /var/lib/drawpile/archived/ -type f -mtime +1 -delete
[Install]
WantedBy=multi-user.target
[Timer]
OnCalendar=daily
[Install]
WantedBy=timers.target
[Path]
PathExistsGlob=/var/lib/drawpile/sessions/*.archived
[Install]
WantedBy=multi-user.target
[Unit]
Description=Drawpile archived sessions render
[Service]
Type=oneshot
ExecStart=drawpile-archives-process.sh
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment