aboutsummaryrefslogtreecommitdiffstats
path: root/script/compact-xapian-database
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-04-09 15:45:33 +0100
committerGareth Rees <gareth@mysociety.org>2014-04-14 16:51:13 +0100
commit82d95f050dbe18576daf36e953d9c2e01330e517 (patch)
treec636de7e62539c644cb28bbf8a172decfe3296f4 /script/compact-xapian-database
parent372e5dc0f2c381fbef9ec0ec17e173b17f860ada (diff)
Fix formatting of compact-xapian-database
Diffstat (limited to 'script/compact-xapian-database')
-rwxr-xr-xscript/compact-xapian-database31
1 files changed, 17 insertions, 14 deletions
diff --git a/script/compact-xapian-database b/script/compact-xapian-database
index f16c4ca37..075a71cd8 100755
--- a/script/compact-xapian-database
+++ b/script/compact-xapian-database
@@ -5,23 +5,26 @@ set -e
cd "$(dirname "$0")"/..
-if [ -x /usr/bin/xapian-compact ]; then
+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" <<SU
- commonlib/bin/output-on-error xapian-compact "\$XAPIAN_DB_DIR/\$RAILS_ENV" "\$XAPIAN_DB_DIR/\$RAILS_ENV.new"
+
+ 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" <<SU
+commonlib/bin/output-on-error xapian-compact "\$XAPIAN_DB_DIR/\$RAILS_ENV" "\$XAPIAN_DB_DIR/\$RAILS_ENV.new"
SU
- 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"
- commonlib/bin/output-on-error /etc/init.d/apache2 restart
+ 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"
+ commonlib/bin/output-on-error /etc/init.d/apache2 restart
fi
-else
+ else
echo >&2 "Could not find xapian-compact script; have you installed xapian-tools?"
exit 1
fi