#!/bin/sh
$ECHO "Updating CVS tree"
cd $COPY
$ECHO "(In directory" `pwd` ")"
/usr/bin/cvs -Q -z9 update -l -d -P -A
cd $COPY/doc
$ECHO "(In directory" `pwd` ")"
/usr/bin/cvs -Q -z9 update -d -P -A
cd $COPY/include
$ECHO "(In directory" `pwd` ")"
/usr/bin/cvs -Q -z9 update -d -P -A
$ECHO "done."
$ECHO

cd $COPY
cp ReleaseNotes.html $WEB_DIR/release-notes.html
cp ReleaseNotes.html $WEB_DIR
cd doc
cp *.html $WEB_DIR
cd www.lesstif.org
cp *.html $WEB_DIR
cp images/*.gif images/*.png images/*.jpg $WEB_DIR/images
$ECHO "done."
$ECHO

$ECHO "Copying Inside LessTif"
cp $COPY/doc/InsideLessTif/html/*.html  $WEB_DIR/InsideLessTif/
cp $COPY/doc/InsideLessTif/html/*.jpeg  $WEB_DIR/InsideLessTif/
cp $COPY/doc/InsideLessTif/html/*.gif   $WEB_DIR/InsideLessTif/
cp $COPY/doc/InsideLessTif/html/*.css   $WEB_DIR/InsideLessTif/
$ECHO "done."
$ECHO

$ECHO "Copying include files to the web site"
cp $COPY/include/Motif-1.2/Xm/*.h   $WEB_DIR/Lessdox/include/Xm/
cp $COPY/include/Motif-2.0/Xm/*.h   $WEB_DIR/Lessdox/include/Xm/
cp $COPY/include/Motif-2.1/Xm/*.h   $WEB_DIR/Lessdox/include/Xm/
cp $COPY/include/Motif-1.2/Mrm/*.h  $WEB_DIR/Lessdox/include/Mrm/
cp $COPY/include/Motif-1.2/uil/*.h  $WEB_DIR/Lessdox/include/uil/
$ECHO "done."
$ECHO

$ECHO "Building HTML documentation from man pages"
cd $COPY/doc/lessdox/clients
for i in `ls *.1 *.5`
do
  $NIGHTLY_DIR/man2html -f -w <$i >${i%.*}.html
done
cd $COPY/doc/lessdox/widgets
for i in `ls *.3`
do
  $NIGHTLY_DIR/man2html -f -w <$i >${i%.*}.html
done
$ECHO "done."
$ECHO

$ECHO "Copying HTML docs to the web site"
cp $COPY/doc/lessdox/clients/*.html $WEB_DIR/Lessdox
cp $COPY/doc/lessdox/widgets/*.html $WEB_DIR/Lessdox
cp $COPY/doc/lessdox/clients/lesstif.html $WEB_DIR/Lessdox/index.html

#
# The logs are on ftp.hungry.com in
#	/var/log/ftp.log.?.gz
# and	/var/log/ftp.log
#
# Their format is
#	Dec 22 07:35:11 terror ftpd[93299]: get pub/hungry/lesstif/srcdist/lesstif-0.93.18.tar.bz2 = 2529161 bytes
# but the path sometimes has a leading / 
#
$ECHO "Create web statistics"
rm -f /tmp/stats.$$
for i in `ls /var/log/ftp.log.?.gz`
do
  zcat <$i | grep /pub/hungry/lesstif | awk -F/ '{print $6}' | awk '{print $1}' >>/tmp/stats.$$
  zcat <$i | grep -v /pub/hungry/lesstif | grep pub/hungry/lesstif | awk -F/ '{print $5}' | awk '{print $1}' >>/tmp/stats.$$
done
cat /var/log/ftp.log | grep /pub/hungry/lesstif | awk -F/ '{print $6}' | awk '{print $1}' >>/tmp/stats.$$
cat /var/log/ftp.log | grep -v /pub/hungry/lesstif | grep pub/hungry/lesstif | awk -F/ '{print $4}' | awk '{print $1}' >>/tmp/stats.$$
fgrep -i -e lesstif -e Xbae -e Xlt </tmp/stats.$$ | sort | uniq >/tmp/sort.$$

echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">'   >$WEB_DIR/stats.html
echo '<html>'                                             >>$WEB_DIR/stats.html
echo '<title>ftp.hungry.com download statistiscs</title>' >>$WEB_DIR/stats.html
echo '<body bgcolor="#ffffff" text="#000000">'            >>$WEB_DIR/stats.html
echo '<h1 align=center>ftp.hungry.com download statistiscs</h1>' >>$WEB_DIR/stats.html
echo '<center>'                                           >>$WEB_DIR/stats.html
echo '<table border=1>'                                   >>$WEB_DIR/stats.html
echo '<tr>'                                               >>$WEB_DIR/stats.html
echo '<th>Package'                                        >>$WEB_DIR/stats.html
echo '<th>#'                                              >>$WEB_DIR/stats.html
for i in `cat /tmp/sort.$$`
do
  echo '<tr><td>'               >>$WEB_DIR/stats.html
  echo $i                       >>$WEB_DIR/stats.html
  echo '</td><td>'              >>$WEB_DIR/stats.html
  grep $i /tmp/stats.$$ | wc -l >>$WEB_DIR/stats.html
  echo '</td></tr>'             >>$WEB_DIR/stats.html
done
echo '</table>'                 >>$WEB_DIR/stats.html
echo '</center>'                >>$WEB_DIR/stats.html
echo '<p><small>'               >>$WEB_DIR/stats.html
echo -n 'Page last updated at ' >>$WEB_DIR/stats.html
date                            >>$WEB_DIR/stats.html
echo '</small>'                 >>$WEB_DIR/stats.html
echo '</body></html>'           >>$WEB_DIR/stats.html

$ECHO "... done"
exit 0
