#!/bin/sh

ncftp sunsite.unc.edu:/pub/Linux/docs/HOWTO/other-formats/html/\*.gz

echo "<!doctype html public \"-//W3C//DTD HTML 3.2 Final//EN\">" > /tmp/howto.$$
echo "<html>" >> /tmp/howto.$$
echo "<head>" >> /tmp/howto.$$
echo "<title>Linux HOWTO's</title>" >> /tmp/howto.$$
echo "</head>" >> /tmp/howto.$$
echo "<body bgcolor=\"#ffffff\">" >> /tmp/howto.$$
DATE=`date`
echo "<! Automatically generated on $DATE.>" >> /tmp/howto.$$
echo "<center> <h1>Linux HOWTO's</h1> </center>" >> /tmp/howto.$$
for file in *.gz ; do
   HOWTO=`echo $file | sed 's/-html.*//'`
   echo "<li> <a href=\"$HOWTO/$HOWTO.html\">$HOWTO</a>" >> /tmp/howto.$$
   /bin/rm -rf $HOWTO
   /bin/mkdir $HOWTO
   cd $HOWTO
   tar zxf ../$file
   # These should only be done once.
   if [ ! -f ../next.gif ] ; then
      /bin/cp next.gif ..
   fi
   if [ ! -f ../prev.gif ] ; then
      /bin/cp prev.gif ..
   fi
   if [ ! -f ../toc.gif ] ; then
      /bin/cp toc.gif ..
   fi
   rm *.gif
   ln -s ../next.gif next.gif
   ln -s ../prev.gif prev.gif
   ln -s ../toc.gif toc.gif
   cd ..
   rm $file
done
echo "<li> <a href=\"mini\">Mini HOWTO's</a>" >> /tmp/howto.$$
echo "<br> <br> <hr>" >> /tmp/howto.$$
echo "<address>Automatically generated by John Gotts &lt<a href=\"mailto:jgotts@engin.umich.edu\">jgotts@engin.umich.edu</a>&gt.</address>" >> /tmp/howto.$$
echo "</body>" >> /tmp/howto.$$
echo "</html>" >> /tmp/howto.$$
/bin/mv -f /tmp/howto.$$ index.html
