diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-04-09 15:43:29 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-04-14 16:49:23 +0100 |
commit | 372e5dc0f2c381fbef9ec0ec17e173b17f860ada (patch) | |
tree | cab7f357717d5fce595e0c5103c46305faf21fd4 /script/compact-xapian-database | |
parent | f50c514379d78174f26cbc6cb3fab8c519df646b (diff) |
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.
Diffstat (limited to 'script/compact-xapian-database')
-rwxr-xr-x | script/compact-xapian-database | 8 |
1 files changed, 5 insertions, 3 deletions
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" <<SU - xapian-compact "\$XAPIAN_DB_DIR/\$RAILS_ENV" "\$XAPIAN_DB_DIR/\$RAILS_ENV.new" + 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" - /etc/init.d/apache2 restart + commonlib/bin/output-on-error /etc/init.d/apache2 restart fi else echo >&2 "Could not find xapian-compact script; have you installed xapian-tools?" |