From 372e5dc0f2c381fbef9ec0ec17e173b17f860ada Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 9 Apr 2014 15:43:29 +0100 Subject: Suppress non-error output compact-xapian-database Cron sends an email for all output, whereas generally we only want to get an email if the command exited in error. --- script/compact-xapian-database | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'script/compact-xapian-database') diff --git a/script/compact-xapian-database b/script/compact-xapian-database index 982c0e878..f16c4ca37 100755 --- a/script/compact-xapian-database +++ b/script/compact-xapian-database @@ -3,8 +3,10 @@ export RAILS_ENV=$1 set -e +cd "$(dirname "$0")"/.. + if [ -x /usr/bin/xapian-compact ]; then - XAPIAN_DB_DIR=$( cd "$( dirname "$0" )" && pwd )/../lib/acts_as_xapian/xapiandbs + 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 @@ -12,12 +14,12 @@ if [ -x /usr/bin/xapian-compact ]; then 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?" -- cgit v1.2.3 From 82d95f050dbe18576daf36e953d9c2e01330e517 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 9 Apr 2014 15:45:33 +0100 Subject: Fix formatting of compact-xapian-database --- script/compact-xapian-database | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'script/compact-xapian-database') 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" <&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 -- cgit v1.2.3