#!/bin/bash # 1-59/5 * * * * /etc/sphinx/sphinx_rotate.sh /path_to_example1.com # 4 3 * * * indexer itemsIndexMain --quiet --rotate # 1-59/5 * * * * indexer itemsIndexDelta --quiet --rotate; indexer --quiet --merge itemsIndexMain itemsIndexDelta --rotate indexer="/usr/bin/indexer --config /etc/sphinx/sphinx.conf --quiet --rotate " if [ $# -eq 0 ]; then echo "Usage: sphinx_rotate.sh [Path to project]" exit 1; fi if [ ! -f /usr/bin/indexer ]; then echo "indexer not found. Check sphinx installation." exit 1; fi for project in "$@"; do if [ ! -d "$project" ]; then echo "Project not found: $project"; continue; fi; path="$project"/files/sphinx if [ ! -d "$path" ]; then continue; fi; main="$path/mode_main_rotate" if [ -f "$main" ]; then for file in "$path"/main_*; do if [ ! -f "$file" ]; then continue; fi; name=$(< "$file") $indexer "$name" done rm -f "$main" else delta="/delta_"; for file in "$path$delta"*; do if [ ! -f "$file" ]; then continue; fi; delta_name=$(< "$file") l=${#path} d=${#delta} let "l = l + d" main=${file:l} main="$path/main_$main" if [ ! -f "$main" ]; then continue; fi; main_name=$(< "$main") $indexer "$delta_name" $indexer --merge "$main_name" "$delta_name" done fi for file in "$path"/rotate_*; do if [ ! -f "$file" ]; then continue; fi; name=$(< "$file") $indexer "$name" rm -f "$file" done done