#!${dash-output:dash}

STATUS_DIR=$${directory:status}
RSS_DIR=$${directory:www}

TAIL=${coreutils-output:tail}
PYTHON=${buildout:bin-directory}/${rssgen-eggs:interpreter}
STATUS2RSS=${status2rss:output}
BASENAME=${coreutils-output:basename}

for status in $STATUS_DIR/*.txt
do
  NAME=`$BASENAME $status`
  $TAIL -n 1 -q $status | $PYTHON $STATUS2RSS "Backup status $NAME" "https://[$${nginx-configuration:ip}]:$${nginx-configuration:port}/$NAME.rss" > $RSS_DIR/$NAME.rss
done

$TAIL -n 1 -q $STATUS_DIR/*.txt | $PYTHON $STATUS2RSS "Full backup status $${:global_rss}" "https://[$${nginx-configuration:ip}]:$${nginx-configuration:port}/$${:global_rss}" > $RSS_DIR/$${:global_rss}
