#!@BASH@

#
# new-db 1.1
#
# Copyright (c) 1998-1999 The ht://Dig Group
# Distributed under the terms of the GNU General Public License (GPL)
#   version 2 or later.
# for the ht://Dig search system http://www.htdig.org/
# and the multidig script system http://www.htdig.org/contrib/scripts/
#
# syntax:
# new-db <db>
#
# Creates a new database directory and conf file with given name 
# Updates the global db.list file
#

# You may need to set the following:
MULTIDIG_CONF=@CONFIG_DIR@/multidig.conf
source $MULTIDIG_CONF

# Catch people who don't supply an argument
if [ "$1" = "" ]; then
    echo Syntax: new-db \<db\>
    exit
fi

# Add the new database to the db.list file
echo ${1:?You need to specify a database} >>$DB_LIST

# Now make the appropriate database directory
mkdir $DB_BASE/$1

# And make a copy of the default (db.conf) conf file for the DB
# Use sed to replace @DATABASE@ with the name of the database
sed -e s%@DATABASE@%$1% $DB_CONF >$CONFIG_DIR/$1.conf
# And make a blank file for the ${start_urls} directive
touch $DB_BASE/$1/$1.urls
