#!/bin/bash

if [ "$(whoami)" != "josv" ]; then
	echo You are not josv, therefore you must go away...
	exit 1
fi

SRC=~josv/c
WWW=~josv/www
VERSION=$(grep ^Version: README | awk '{print $2}')

echo Publish proxytunnel $VERSION

cd $SRC
rm proxytunnel
mv proxytunnel* proxytunnel-$VERSION
ln -s proxytunnel-$VERSION proxytunnel
cd $WWW/proxytunnel
rm proxytunnel*.tar.gz
cp $SRC/proxytunnel/README .
cd $SRC
tar czvf $WWW/proxytunnel/proxytunnel-$VERSION.tar.gz proxytunnel-$VERSION
cd $WWW/proxytunnel
sed "s/==VERSION==/$VERSION/g" <index.html.in >index.html
cd $WWW
scp -r proxytunnel tjosv:www
