#!/bin/bash

CAMPDIR=/home/staff/meidanis/aulas/mc600/campdir
PUBDIR=/home/staff/meidanis/public_html/courses/mc600/200002/LispOfficial

rcamp=rcamp$1.txt
final=final$1.txt
echo $rcamp

pushd $CAMPDIR
ls -1t *.lsp *.fsl | sed 's/.lsp//;s/.fsl//' | gawk 'BEGIN{print "(setf jogadores '\''("}{print}END{print "))"}' > $PUBDIR/jogadores.lsp
echo "Campeonato iniciado: " > $PUBDIR/$rcamp
date >> $PUBDIR/$rcamp
xlisp $PUBDIR/lp.lsp > $PUBDIR/tmprcamp
tail -1 $PUBDIR/tmprcamp >> $PUBDIR/$rcamp
echo >> $PUBDIR/$rcamp
cat $PUBDIR/tmprcamp >> $PUBDIR/$rcamp
date > $PUBDIR/$final
popd
pushd $PUBDIR
echo "" | ./faztab.pl > $PUBDIR/tabela.html
echo "" | ./notas.pl > $PUBDIR/notas.html
popd
