#! /bin/bash
#
# Publish the po files in speedier-int as the user and 
# in the directory specfic to each developer

if [ -z "$1" ] ; then
    echo "$0 --username"
    echo "   Known usernames:"
    echo "        --gafton"
    exit -1
fi

#default values
USEROPT=""
USERDIR=""
MACHINE=gonzales.redhat.com

case "$1" in 
    --gafton )
	USEROPT="-l gafton"
	USERDIR="/raid/ftp.redhat.com/pub/home/gafton/i18n"
	;;
    *)
	echo "You ($1) are unknown to me. Edit this script first"
	exit -1
esac


[ -z "$USERDIR" ] && exit -1
[ -z "$USEROPT" ] && exit -1

rm -f translations-*.tar.gz
make clean
make tar || {
    echo "Error making tar file; Are you running  this script in the project directory?"
    exit -1;
}

DATE=`date +"%y%m%d"`
ARCHIVE=translations-$DATE.tar.gz

[ -f $ARCHIVE ] && gunzip -dc $ARCHIVE | \
ssh $USEROPT $MACHINE "(
[ ! -d $USERDIR ] && rm -rf $USERDIR 
mkdir -p $USERDIR || exit -1
cd $USERDIR || exit -1
tar xvf -
)" || {
    echo "Update of $ARCHIVE failed."
    exit -1
}

