x86_64-alpine-get_iplayer/files/etc/periodic/daily/get_iplayer_update
Jonny Ervine 3dcc4b486d new file: Dockerfile
new file:   Jenkinsfile
	new file:   files/etc/crontabs/root
	new file:   files/etc/logrotate.d/get_iplayer
	new file:   files/etc/periodic/daily/get_iplayer_update
	new file:   files/etc/periodic/hourly/get_iplayer_pvr
	new file:   files/start
Initial commit
2020-02-18 09:50:10 +00:00

13 lines
927 B
Bash

#!/bin/sh
#
# Check for get_iplayer update.
# When updating will kill any active downloads launched from web front-end, but not those launched by hourly background PVR.
#
(
OLD=`get_iplayer -V 2>&1 | sed -nE 's/get_iplayer v(\d+)\.(\d+).*/\1\2/p'` # e.g. 321
wget -qO - "https://api.github.com/repos/get-iplayer/get_iplayer/releases/latest" > /tmp/latest.json
NEW=`jq -r .name /tmp/latest.json | sed -nE 's/v(\d+)\.(\d+).*/\1\2/p'` # e.g. 322
[ ! -z "$OLD" ] && [ ! -z "$NEW" ] && [ $OLD -lt $NEW ] && echo "Updating get_iplayer $OLD -> $NEW" 1>&2 && wget -qO - "`jq -r .tarball_url /tmp/latest.json`" | tar -zxf - && cd get-iplayer* && install -m 755 -t /usr/local/bin ./get_iplayer ./get_iplayer.cgi && cd $OLDPWD && rm -rf get-iplayer* && PID=`ps | grep "/usr/local/bin/get_iplayer.cgi" | grep -v grep | cut -c1-6` && [ ! -z "$PID" ] && kill $PID
) 2>> /var/log/get_iplayer_update.log
rm -f /tmp/latest.json