#!/bin/sh # Copyright (C) 2006 Michael Daum # # This file is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ME=`whoami` # read the config file GETFEEDS_PRG=`realpath $0` GETFEEDS_DIR=`dirname $GETFEEDS_PRG` CONFIG_FILE="$GETFEEDS_DIR/getfeeds.conf" test -f $CONFIG_FILE && source $CONFIG_FILE # default values test -z "$VIEW_URL" && VIEW_URL="http://localhost/~$ME/cgi-bin/twiki/view" test -z "$FEEDS_DIR" && FEEDS_DIR="$HOME/public_html/feeds" test -z "$TWIKI_DIR" && TWIKI_DIR="$HOME/twiki" test -z "$LOG_FILE" && LOG_FILE="$TWIKI_DIR/data/getfeeds.log" test -z "$EXCLUDE_WEBS_PATTERN" && EXCLUDE_WEBS_PATTERN='\.txt|\.log|^_|Trash|Attic|TestCases|mime.types|RegistrationApprovals' test -z "$EXCLUDE_TOPICS_PATTERN" && EXCLUDE_TOPICS_PATTERN="Base.txt" test -z "$WEBS" && WEBS="`ls $TWIKI_DIR/data | egrep -v $EXCLUDE_WEBS_PATTERN`" test -z "$SLEEP" && SLEEP=1 # do it ( date +"*** starting $GETFEEDS_PRG %Y-%m-%d : %k:%M:%S" for WEB in $WEBS; do FEEDS="`ls $TWIKI_DIR/data/$WEB/WebRss*txt $TWIKI_DIR/data/$WEB/WebAtom*txt|egrep -v $EXCLUDE_TOPICS_PATTERN|sed 's/^.*\/\(.*\)\.txt$/\1/g'`" for TOPIC in $FEEDS; do OUT_FILE="$FEEDS_DIR/$WEB$TOPIC.xml" TMP_FILE="/tmp/$WEB$TOPIC.xml" echo "*** fetching $WEB.$TOPIC into $OUT_FILE" wget -q -O $TMP_FILE $VIEW_URL/$WEB/$TOPIC?t=`date +"%s"` && mv $TMP_FILE $OUT_FILE && chmod go+r $OUT_FILE sleep $SLEEP done done echo "*** done $GETFEEDS_PRG" ) >> $LOG_FILE 2>&1