aboutsummaryrefslogtreecommitdiffstats
path: root/script/compact-xapian-database
diff options
context:
space:
mode:
authorDavid Cabo <david@calibea.com>2011-08-12 13:12:50 +0200
committerDavid Cabo <david@calibea.com>2011-08-12 13:12:50 +0200
commitdf1754847892bb6abce2681a42d8c50cf8d3a2da (patch)
tree73c518103906ad446cedd55c69690d8d91f0f362 /script/compact-xapian-database
parenta63e598b9e0ddfa7ac695b1be41aaace6c0eb628 (diff)
parent766df1c7de8f820bd6e451526787632a136bc635 (diff)
Merge branch 'master' of github.com:sebbacon/alaveteli into asktheeu
Conflicts: locale/cy/app.po locale/de/app.po locale/es/app.po locale/fr/app.po locale/sq/app.po locale/sr/app.po locale/sr@latin/app.po
Diffstat (limited to 'script/compact-xapian-database')
-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