2013-07-09 10:12:42 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
set -o nounset
|
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
MAINTMPFILE="/var/run/piler/main.indexer.tmp"
|
|
|
|
SPHINX_CONFIG="SYSCONFDIR/piler/sphinx.conf"
|
2021-01-06 08:38:29 +01:00
|
|
|
PRIORITY="mail.info"
|
2020-11-13 21:08:11 +01:00
|
|
|
TOUCHFILE="/var/piler/stat/indexer"
|
|
|
|
MAIN_INDEX="main1"
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
finish() {
|
|
|
|
rm -f "$MAINTMPFILE"
|
2013-07-09 10:12:42 +02:00
|
|
|
}
|
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
date > "$MAINTMPFILE"
|
|
|
|
|
|
|
|
touch "$TOUCHFILE"
|
|
|
|
|
2013-07-09 10:12:42 +02:00
|
|
|
trap finish EXIT
|
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
echo "INDEXER INFO: merging to main started" | logger -p "$PRIORITY"
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
indexer --config "$SPHINX_CONFIG" --quiet --merge "$MAIN_INDEX" dailydelta1 --merge-dst-range deleted 0 0 --rotate
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
echo "INDEXER INFO: merging to main finished" | logger -p "$PRIORITY"
|
2013-07-09 10:12:42 +02:00
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
echo "INDEXER INFO: resetting daily delta started" | logger -p "$PRIORITY"
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
indexer --config "$SPHINX_CONFIG" --quiet dailydelta1 --rotate
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
echo "INDEXER INFO: resetting daily delta finished" | logger -p "$PRIORITY"
|
2013-07-09 10:12:42 +02:00
|
|
|
|
2020-11-13 21:08:11 +01:00
|
|
|
sum=0
|
|
|
|
while read -r a b; do
|
|
|
|
sum=$(( sum + b ))
|
|
|
|
done < <( find /var/piler/sphinx/ -type f -name main\*.spd -printf "%TY%Tm%Td %s\\n" )
|
|
|
|
printf "%d" $sum > /var/piler/stat/main_index_size
|