Project

General

Profile

tickets #16070 » check_feeds.sh

check_feeds.sh - cboltz, 2017-03-18 18:03

 
#!/bin/bash

test -n "$1" || {
echo "Usage: $0 feedfile"
echo
echo 'feedfile can be planetsuse/feeds or a broken-feeds-$DATE file.'
echo
echo 'A list of broken feeds will be saved as "broken-feeds-$DATE" in the current directory.'
exit 1
}

feedfile="$1"

reportfile="broken-feeds-$(date '+%Y-%m-%d')"

test "$feedfile" = "$reportfile" && { echo "Aborting - output file and feed list are the same file ($feedfile). Please rename the feed list!"; exit 1; }

echo "Checking feeds in $feedfile..."

for feed in $( grep ^feed "$feedfile" | awk '{print $3}' ) ; do
wget -O /dev/null "$feed" -q --timeout 20 --tries 2 && echo "ok: $feed" || { echo "feed x $feed" >> "$reportfile"; echo "BROKEN: $feed"; }
done

echo
test -f "$reportfile" && echo "The list of broken feeds has been saved to $reportfile" || echo "No broken feeds :-)"
(1-1/3)