#!/bin/sh
#---------#---------#---------#---------#---------#---------#---------#---------
#
# title
#   turn a directory into an HTML page of links
# author
#   idc@planetlarg.net 12/08/03
# description
#   Turn a directory contents into a web page. 
#   Only deals with files.
# modifications
#
#---------#---------#---------#---------#---------#---------#---------#---------
# setup
    usage_message="
    usage:
      $0 -o some-option
    example:
      the command
         $0 -o stuff
      returns
         something
    description
      Does some stuff.
      Doesn't do other stuff.
    "
# command line options
    # options provided? tell the punter how to use this utility
    if [ $# -ne 0 ]; then
      echo "options were provided."
      echo "$usage_message" 1>&2
      exit 1
    fi

# variables
    dir=/var/www/www.isp01.com/pub/
    out=$dir/index.html
# main
    # header
    echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dir links</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
" > $out
    # body
    for i in `ls $dir`
    do
        echo "<a href=$i> $i </a> <br>" > $out
    done

    # footer
    echo "
</body>
</html>
" > $out


   # clean up
   chown user01:user01 $out
   chmod 644 $out

