#!/bin/sh
# maketar.sh -- make a tar update file

days="$1"

if [ -z "$days" ]
then
	echo "Syntax: $0 days"
	exit
fi

case "$days" in
[0-9]*)	;;
*)	echo "$0: Error: days is not numeric"
	exit
	;;
esac

pwd=$(pwd)

case "$pwd" in
*/wb)	;;
*)	echo "$0: Error: you must be in the top level directory"
	exit
	;;
esac

if [ ! -f index.html ]
then
	echo "$0: Error: index.html not found"
	exit
fi

rm -f ./*.html- ./*/*.html- ./*/*/*.html- new*.html- junk.tmp
rm -rf .xvpics ./*/.xvpics ./*/*/.xvpics ./*/*/*/.xvpics

if [ -x listnewfiles.sh ]
then
	./listnewfiles.sh
else
	echo "$0: Warning: Could not run listnewfiles.sh"
fi

if [ -x fixpriv.sh ]
then
	./fixpriv.sh
else
	echo "$0: Warning: Could not run fixpriv.sh"
fi

file=../w.tar.bz2

rm -f "$file" newpages.html- newimages.html-

pdtar -S "$days" -cvof - . | bzip2 -v9 > "$file"

ls -l "$file"
