#!/bin/sh
##--------------------------------------------------------------------------##
##  File:
##	$Id: mk-search-index,v 1.4 2002/09/13 07:25:55 ehood Exp $
##  Description:
##	Create/update search index for list.  The name of the
##	list is specified on the command-line.
##
##	NOTE: This script is probably no longer needed since
##	      web-archive calls the search indexing tool directly.
##--------------------------------------------------------------------------##
##  Copyright (C) 2001-2002	Earl Hood <earl@earlhood.com>
##
##  This program is free software; you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation; either version 2 of the License, or
##  (at your option) any later version.
##  
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##  
##  You should have received a copy of the GNU General Public License
##  along with this program; if not, write to the Free Software
##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
##  02111-1307, USA
##--------------------------------------------------------------------------##

if [ ! -z "$GATEWAY_INTERFACE" ]; then
  echo "CGI use FORBIDDEN!"
  exit 1
fi

if [ $# -ne 1 ]; then
  echo "Invalid invocation."
  exit 1
fi
list=$1

PATH=$HOME/bin:/usr/local/bin:/usr/bin:/bin; export PATH
BASEDIR=`dirname $0`

# Load configuration
. $BASEDIR/../lib/config.sh

# Sanity checks
if [ ! -e "$MKNMZ_RC" ]; then
  echo "$MKNMZ_RC does not exist!"
  exit 1
fi
if [ ! -d "$MKNMZ_TMPL_DIR" ]; then
  echo "$MKNMZ_TMPL_DIR is not a directory!"
  exit 1
fi
if [ ! -d "$HTML_DIR/$list" ]; then
  echo "$HTML_DIR/$list is not a directory!"
  exit 1
fi

$MKNMZ --mhonarc \
       -f "$MKNMZ_RC" \
       -T "$MKNMZ_TMPL_DIR" \
       -O "$HTML_DIR/$list" \
       "$HTML_DIR/$list"
