#!/bin/bash

cd /fenris
make clean

LCODE=$[`tar cf - /fenris 2>/dev/null | wc -l`]
BYTES=$[`tar cf - /fenris 2>/dev/null | wc -c`]
CBUILD="`cat doc/.build`"
DATE="`date +'%A, %d %B %Y, %H:%M'`"

TAG="$CBUILD ($[BYTES/1024]kB), uploaded at $DATE EST"

tar cfvz /fenris.tgz /fenris
scp /fenris.tgz lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/
rm -f /fenris.tgz
scp -C /fenris/README lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/

sed "s/CURRENTBUILD/$TAG/g" </fenris/html/devel.shtml >/tmp/index.shtml
scp -C /tmp/index.shtml lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/devel.shtml
rm -f /tmp/index.shtml
cd html
scp -C fenris-ui.html lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/
scp -C index.shtml lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/
cd ../doc
scp -C reverse.txt lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/

#scp /fenris/html/fenris.jpg lcamtuf@coredump.cx:/export/www/lcamtuf/fenris/

echo
echo "Lines of code: $LCODE"
echo "Characters:    $BYTES"
echo "Build:         $CBUILD"
echo "Date:          $DATE"

