#!/bin/sh
#
# Prepare the autobuild website for a new run.
# This script is called by autobuild during startup.
# Orion Sky Lawlor, olawlor@acm.org, 2002/2/3
#

source config

# Exit giving this reason for failure.
Die() {
	echo "web fatal> " $@ 
	exit 1
}

# Run this command or die
Do() {
	echo "web> " $@
	$@ 
	err="$?"
	if [ $err -ne 0 ] 
	then
		Die "error code $err during web> " $@ 
	fi
}

rm -fr web/*

newDir="old."`date +"%Y_%m_%d__%H_%M"`
echo "update_web_start> Making web directory at $newDir"
Do ssh $webMachine << END_REMOTE
cd $webMachPath
rm -fr bin/*
(cd bin && ln -s charm-5.8_src.tar.gz charm-5.8.tar.gz)
rm prev
mv cur prev
mkdir $newDir
ln -s $newDir cur
cd cur
cat > index.html << END_HTML
<html>
<title>Charm++ 5.8 Automated-Build Status</title>
<body bgcolor="#ffFFff">
<h1>Charm++ 5.8 Automated-Build Starting...</h1>
Charm++ automated build started on `date`<br>
No compilations have finished yet.<br>
Return to <a href="/">Charm++ Home Page</a>
</BODY></HTML>
END_HTML

END_REMOTE

