#!/bin/sh

set -e

if [ $# != 2 -o "$1" != "up" -a "$1" != "down" ] ; then
echo "Usage: $0 {up|down} Username" ; exit 1 ; fi

if [ "$1" = "down" ]
then
	rsync -rltzv --delete --exclude 'maintain.sh' \
	      "$2@www.rocklinux.org::rock-people-$2" .
else
	wget http://www.rocklinux.net/rock.sed -O /tmp/$$.sed
	find -name '*.html' | xargs rm -vf
	find -name '*.in' | while read x ; do
		echo "Creating ${x%.in}.html ..."
		sed -f /tmp/$$.sed < $x > ${x%.in}.html
	done
	rm -f /tmp/$$.sed

	rsync -rltzv --delete --exclude 'maintain.sh' \
	      . "$2@www.rocklinux.org::rock-people-$2"
fi

