piler/util/indexer.delta.sh.in

44 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2013-07-09 10:12:42 +02:00
#!/bin/bash
2013-07-09 11:32:48 +02:00
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
2013-07-09 10:12:42 +02:00
MAINTMPFILE=/var/run/piler/main.indexer.tmp
DELTATMPFILE=/var/run/piler/delta.indexer.tmp
INDEXER="indexer --config SYSCONFDIR/piler/sphinx.conf"
PRIORITY=mail.info
2013-08-09 10:13:54 +02:00
TOUCHFILE=/var/piler/stat/indexer
CONFIG_FILE=sphinx.conf
2013-07-09 10:12:42 +02:00
if [[ -f SYSCONFDIR/piler/MANTICORE ]]; then
CONFIG_FILE=manticore.conf
fi
2013-07-09 10:12:42 +02:00
INDEXER="indexer --config SYSCONFDIR/piler/${CONFIG_FILE}"
if [[ -f "$MAINTMPFILE" ]]; then echo "INDEXER ERROR: indexer merging to main index is already running. It started at $(cat "$MAINTMPFILE")" | logger -p "$PRIORITY" ; exit 1; fi
if [[ -f "$DELTATMPFILE" ]]; then echo "INDEXER ERROR: delta indexing and merging is already running. It started at $(cat "$DELTATMPFILE")" | logger -p "$PRIORITY" ; exit 1; fi
2013-07-09 10:12:42 +02:00
date > $DELTATMPFILE
2013-08-09 10:13:54 +02:00
touch $TOUCHFILE
2013-07-09 10:12:42 +02:00
function finish {
rm -f $DELTATMPFILE
}
trap finish EXIT
echo "INDEXER INFO: indexing delta1 started" | logger -p $PRIORITY
$INDEXER --quiet delta1 --rotate
echo "INDEXER INFO: indexing delta1 finished" | logger -p $PRIORITY
sleep 5
echo "INDEXER INFO: merging delta to dailydelta started" | logger -p $PRIORITY
$INDEXER --quiet --merge dailydelta1 delta1 --merge-dst-range deleted 0 0 --rotate
echo "INDEXER INFO: merging delta to dailydelta finished" | logger -p $PRIORITY