aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-08-11 15:39:05 +0100
committerSeb Bacon <seb.bacon@gmail.com>2011-08-11 15:43:05 +0100
commiteb616008189c6db73e88a65505e57eabfbfe453c (patch)
tree68a2c064ab00b0d311cb4296c162cd2c6f1cde1c /script
parent8d75b913cb4b14a143ccc0a418c7af6e7d33d82f (diff)
Compact database regularly. Fixes #127.
Diffstat (limited to 'script')
-rwxr-xr-xscript/compact-xapian-database16
1 files changed, 16 insertions, 0 deletions
diff --git a/script/compact-xapian-database b/script/compact-xapian-database
new file mode 100755
index 000000000..5c12b5dae
--- /dev/null
+++ b/script/compact-xapian-database
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+RAILS_ENV=$1
+set -e
+if [ -x /usr/bin/xapian-compact ]; then
+ XAPIAN_DB_DIR="$( cd "$( dirname "$0" )" && pwd )/../vendor/plugins/acts_as_xapian/xapiandbs"
+ OWNER=`stat -c %U $XAPIAN_DB_DIR/$RAILS_ENV`
+ su -c "xapian-compact $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.new" $OWNER
+ mv $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.tmp
+ mv $XAPIAN_DB_DIR/$RAILS_ENV.new $XAPIAN_DB_DIR/$RAILS_ENV
+ rm -rf $XAPIAN_DB_DIR/$RAILS_ENV.tmp
+ /etc/init.d/apache2 restart
+else
+ echo "Could not find xapian-compact script; have you installed xapian-tools?"
+ exit 1
+fi \ No newline at end of file