#!/bin/sh
# update mnogosearch database
#
# to configure mnogosearch, see /etc/mnogosearch
# and /usr/share/doc/mnogosearch-*
#
MAINCONFIG=/etc/mnogosearch/indexer.conf

if [ ! -f $MAINCONFIG ]; then
    # no config: exit quietly
    exit 0
fi

if [ ! -x /usr/bin/indexer ]; then
    echo "can't execute /usr/bin/indexer" >&2
    exit 1
fi

# are we called by the correct user?
if [ ! -O /var/lib/mnogosearch ]; then
    echo "indexing can only be done by the mnogosearch user" >&2
    exit 1
fi

BASICOPTIONS="-v 0 -d $MAINCONFIG"

# crawl the URLs
/usr/bin/indexer $BASICOPTIONS --crawl -b -e
# create a search index
/usr/bin/indexer $BASICOPTIONS --index
# create word statistics for suggestions
/usr/bin/indexer $BASICOPTIONS --wordstat
