#!/bin/sh
# Inspired from the original source
# taken from then sunsite binary distribution for slrn.0.9.4.6
# Modified by AGX <agx@linut.it> on 19990222 to work on "Bad Penguin"

# Configuration variables.  Change these!!!
dir=/var/spool/slrnpull
server=news.peoples.it

EXPIRE=0
REPOST=0
while [ ! "$1" = "" ]; do
  case $1 in
    --expire|-e)
      EXPIRE=1
      ;;
    --repost|-r)
      REPOST=1
      ;;
  esac
  shift 1
done

# Before getting new articles, perform expiration.
if [ $EXPIRE -eq 1 ]; then
  echo "Expiring Articles ..."
  slrnpull -d $dir --expire
fi

if [ $REPOST -eq 1 ]; then
  for i in $dir/out.going/rejects/*; do
    if [ -f $i ]; then
      echoc CYAN "Re-posting rejected articles $i"
      mv $i $dir/out.going/
    fi
  done
fi

echo "Retrieving Articles ..."
umask 022
slrnpull -d $dir -h $server
