#!/bin/bash export RAILS_ENV=$1 set -e cd "$(dirname "$0")"/.. if [ -x /usr/bin/xapian-compact ]; then XAPIAN_DB_DIR=$( pwd )/lib/acts_as_xapian/xapiandbs if [ -e "$XAPIAN_DB_DIR/$RAILS_ENV.new" ]; then echo >&2 "Didn't compact Xapian database because there was an existing database at $XAPIAN_DB_DIR/$RAILS_ENV.new" exit 1 else OWNER=$(stat -c %U "$XAPIAN_DB_DIR/$RAILS_ENV") export XAPIAN_DB_DIR RAILS_ENV su "$OWNER" <&2 "Could not find xapian-compact script; have you installed xapian-tools?" exit 1 fi