301
+ − 1 #!/bin/sh
442
+ − 2 # $Id: noffle-cronfetch 585 2003-06-25 15:34:53Z godisch $
301
+ − 3 #
+ − 4 # noffle script to fetch articles, run from cron
+ − 5
+ − 6 exec > /dev/null 2>&1
+ − 7
+ − 8 LOCKFILE=/var/lock/noffle/noffle-cronfetch.pid
+ − 9 NOFFLE=/usr/bin/noffle
+ − 10
+ − 11 . /etc/default/noffle
+ − 12
+ − 13 [ "$NOFFLE_FETCHMODE" = cron ] || exit 0
+ − 14
+ − 15 if [ -f "$LOCKFILE" ]; then
+ − 16 # check if pid still exists
442
+ − 17 if kill -0 `cat "$LOCKFILE"`; then
301
+ − 18 logger -i -p news.info -t noffle-cronfetch -- "previous instance still running"
+ − 19 exit 0
+ − 20 fi
+ − 21 # false lock
+ − 22 logger -i -p news.warning -t noffle-cronfetch -- "removing stale lock $LOCKFILE"
442
+ − 23 rm -f "$LOCKFILE"
301
+ − 24 fi
+ − 25
442
+ − 26 trap 'rm -f "$LOCKFILE"' 0 1 2 15
301
+ − 27
442
+ − 28 echo "$$" > "$LOCKFILE"
+ − 29 "$NOFFLE" --fetch
+ − 30 rm -f "$LOCKFILE"
301
+ − 31
+ − 32 trap '' 0
+ − 33 exit 0