#!/bin/bash
#
# $Id$
#
# Delivery of the Web site in a DocumentRoot
#
#
# Please replace with your destination
#
DESTDIR=/var/www/html/mondo
DESTUSER=apache
MONDODIR=/mondo/www/html/mondo
TESTDIR=/mondo/www/html/test

/sbin/ifconfig | grep -q 10.3.3 2>&1 > /dev/null
if [ $? = 0 ]; then
	DESTMACH=mondo.hpintelco.org
else
	DESTMACH=www1.mondorescue.org
fi

dname=`dirname $0`
prem=`echo $dname |cut -c1`
if [ ${prem} == "/" ]; then
        export TOOLHOME=$dname
else
        export TOOLHOME=${PWD}/$dname
fi

. $TOOLHOME/common-env

rm -rf $DESTDIR
cp -a ${BASE}/svn/${VER}/website $DESTDIR
(cd ${BASE}/svn/${VER}/documentation ; make)
mkdir -p $DESTDIR/docs
cp -a ${BASE}/svn/${VER}/documentation/* $DESTDIR/docs
find $DESTDIR -type d | xargs chmod 755
find $DESTDIR -type f | xargs chmod 644
cd $DESTDIR
if [ _"$1" == _"" ]; then
		exit 0
else
	if [ _"$1" == _"test" ]; then
		DESTDIR=$TESTDIR
	else
		DESTDIR=$MONDODIR
	fi
fi
tar cfj /tmp/mondo-www.tz2 .
ssh ${DESTUSER}@${DESTMACH} "rm -rf ${DESTDIR} ; mkdir ${DESTDIR}"
scp /tmp/mondo-www.tz2 ${DESTUSER}@${DESTMACH}:/tmp
rm -f /tmp/mondo-www.tz2
ssh ${DESTUSER}@${DESTMACH} "cd ${DESTDIR} ; tar xfj /tmp/mondo-www.tz2"
