From c31e553a72d40bf0b1c099284ecbb4b95833e186 Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Thu, 30 May 2013 16:12:13 +1200 Subject: [PATCH] Bug 10379: silence zebra rebuild cron when no instances are enabled This adds a -q option to koha-rebuild-zebra that prevents it outputting help if no instances are provided on the command line. This means that if you've just installed the package, you won't get messages from cron telling you how to use the script. Test plan: * install koha-common 3.12 or master onto a system with no enabled instances. * note that you or the sysadmin will start getting emails every 5 minutes. * replace /etc/cron.d/koha-common and /usr/sbin/koha-rebuild-zebra with the versions from this patch. * note that the emails stop flowing. Signed-off-by: Magnus Enger "sudo koha-rebuild-zebra -q" gives no output, as expected. Followed the test plan, all looks good. Signed-off-by: Galen Charlton --- debian/koha-common.cron.d | 2 +- debian/scripts/koha-rebuild-zebra | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/debian/koha-common.cron.d b/debian/koha-common.cron.d index cd7f3c207d..f763f302d7 100644 --- a/debian/koha-common.cron.d +++ b/debian/koha-common.cron.d @@ -6,5 +6,5 @@ SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra $(koha-list --enabled) +*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled) */15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl diff --git a/debian/scripts/koha-rebuild-zebra b/debian/scripts/koha-rebuild-zebra index f32ca8bbdb..6464958cad 100755 --- a/debian/scripts/koha-rebuild-zebra +++ b/debian/scripts/koha-rebuild-zebra @@ -91,6 +91,7 @@ Options: --authorities|-a Only run process for authorities. --biblios|-b Only run process for biblios. --full|-f Does a reindex of the whole collection. + --quiet|-q Sometimes be a bit quieter for scripts/cronjobs. --verbose|-v Be verbose. --help|-h Print this help. @@ -108,6 +109,9 @@ biblios_only="no" authorities_only="no" biblios="yes" authorities="yes" +# The '-q' option is intended to prevent the cronjob causing this to output +# help information if there are no instances defined. +quiet="no" # Read parameters while [ -n "$*" ]; do @@ -130,6 +134,9 @@ while [ -n "$*" ]; do -v|--verbose) opt_verbose="-v" ;; + -q|--quiet) + quiet="yes" + ;; -*) opts_other="$opts_other $1"; ;; @@ -142,7 +149,14 @@ while [ -n "$*" ]; do done # Parse command line. -[ $# -ge 1 ] || ( usage ; die "Missing instance name..." ) +if [ $# -lt 1 ]; then + if [ "$quiet" = "no" ]; then + usage + die "Missing instance name." + else + exit + fi +fi # Loop over instance names for name in "$@" -- 2.39.2