Bugzilla – Attachment 56662 Details for
Bug 17467
Introduce a single koha-zebra script to handle Zebra daemons for instances
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17467: Add koha-zebra script to handle Zebra daemons
Bug-17467-Add-koha-zebra-script-to-handle-Zebra-da.patch (text/plain), 7.91 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-10-19 13:27:13 UTC
(
hide
)
Description:
Bug 17467: Add koha-zebra script to handle Zebra daemons
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-10-19 13:27:13 UTC
Size:
7.91 KB
patch
obsolete
>From bf88cd5fce7dcd9a52182dc56e754d3928d1e256 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 12 Aug 2016 18:54:07 -0300 >Subject: [PATCH] Bug 17467: Add koha-zebra script to handle Zebra daemons > >This script is intended to replace the following currently used scripts >on packages setups: >- koha-start-zebra >- koha-stop-zebra >- koha-restart-zebra > >It also introduces a --status option switch, for asking for daemon statuses > >To test > >- Apply the patch >- Run: > $ sudo debian/scripts/koha-zebra --start kohadev >=> SUCCESS: same behaviour than koha-start-zebra kohadev >- Run: > $ sudo debian/scripts/koha-zebra --stop kohadev >=> SUCCESS: same behaviour as koha-stop-zebra kohadev >- Run: > $ sudo debian/scripts/koha-zebra --restart kohadev >=> SUCCESS: same behaviour than koha-restart-zebra kohadev >- Run: > $ sudo debian/scripts/koha-zebra --status kohadev >=> SUCCESS: It correctly shows the status for the running (or not) process > >Play with different combinations of this commands >--- > debian/scripts/koha-zebra | 252 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 252 insertions(+) > create mode 100755 debian/scripts/koha-zebra > >diff --git a/debian/scripts/koha-zebra b/debian/scripts/koha-zebra >new file mode 100755 >index 0000000..a2f47e7 >--- /dev/null >+++ b/debian/scripts/koha-zebra >@@ -0,0 +1,252 @@ >+#!/bin/bash >+ >+# koha-zebra - Manage Zebra daemons for Koha instances >+# Copyright 2016 Theke Solutions >+# Copyright 2010 Catalyst IT, Ltd >+# >+# This program is free software: you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation, either version 3 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program. If not, see <http://www.gnu.org/licenses/>. >+ >+set -e >+ >+. /lib/lsb/init-functions >+ >+# Read configuration variable file if it is present >+[ -r /etc/default/koha-common ] && . /etc/default/koha-common >+ >+# include helper functions >+if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then >+ . "/usr/share/koha/bin/koha-functions.sh" >+else >+ echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 >+ exit 1 >+fi >+ >+usage() >+{ >+ local scriptname=$(basename $0) >+ >+ cat <<EOF >+$scriptname >+ >+This script lets you manage the Zebra daemon for your Koha instances. >+ >+Usage: >+$scriptname [--start|--stop|--restart] instancename1 [instancename2...] >+$scriptname -h|--help >+ >+ --start Start the Zebra daemon for the specified instance(s) >+ --stop Stop the Zebra daemon for the specified instance(s) >+ --restart Restart the Zebra daemon for the specified instance(s) >+ --status Show the status of the Zebra daemon for the specified instance(s) >+ --verbose|-v Display progress and actions messages >+ --help|-h Display this help message >+ >+EOF >+} >+ >+start_zebra() >+{ >+ local name=$1 >+ >+ # get zebra log levels from koha-conf.xml >+ local loglevels=$(get_loglevels ${name}) >+ >+ if ! is_zebra_running $name; then >+ >+ _check_and_fix_perms ${name} >+ >+ DAEMONOPTS="--name=${name}-koha-zebra \ >+ --pidfiles=/var/run/koha/${name}/ \ >+ --errlog=/var/log/koha/${name}/zebra-error.log \ >+ --output=/var/log/koha/${name}/zebra-output.log \ >+ --verbose=1 \ >+ --respawn \ >+ --delay=30 \ >+ --user=${name}-koha.${name}-koha" >+ >+ ZEBRA_PARAMS="-v $loglevels \ >+ -f /etc/koha/sites/${name}/koha-conf.xml" >+ >+ [ "$verbose" != "no" ] && \ >+ log_daemon_msg "Starting Koha Zebra daemon for ${name}" >+ >+ if daemon $DAEMONOPTS -- $ZEBRA_DAEMON $ZEBRA_PARAMS; then >+ [ "$verbose" != "no" ] && \ >+ log_end_msg 0 >+ else >+ [ "$verbose" != "no" ] && \ >+ log_end_msg 1 >+ fi >+ else >+ if [ "$verbose" != "no" ]; then >+ log_daemon_msg "Error: Zebra already running for ${name}" >+ log_end_msg 1 >+ fi >+ fi >+} >+ >+stop_zebra() >+{ >+ local name=$1 >+ >+ if is_zebra_running $name; then >+ >+ DAEMONOPTS="--name=${name}-koha-zebra \ >+ --pidfiles=/var/run/koha/${name}/ \ >+ --errlog=/var/log/koha/${name}/zebra-error.log \ >+ --output=/var/log/koha/${name}/zebra-output.log \ >+ --verbose=1 \ >+ --respawn \ >+ --delay=30 \ >+ --user=${name}-koha.${name}-koha" >+ >+ [ "$verbose" != "no" ] && \ >+ log_daemon_msg "Stopping Koha Zebra daemon for ${name}" >+ >+ if daemon $DAEMONOPTS --stop -- $ZEBRA_DAEMON $ZEBRA_PARAMS; then >+ [ "$verbose" != "no" ] && \ >+ log_end_msg 0 >+ else >+ [ "$verbose" != "no" ] && \ >+ log_end_msg 1 >+ fi >+ else >+ if [ "$verbose" != "no" ]; then >+ log_daemon_msg "Error: Zebra not running for ${name}" >+ log_end_msg 1 >+ fi >+ fi >+} >+ >+restart_zebra() >+{ >+ local name=$1 >+ >+ if is_zebra_running ${name}; then >+ >+ stop_zebra ${name} && \ >+ start_zebra ${name} >+ else >+ if [ "$verbose" != "no" ]; then >+ log_daemon_msg "Error: Zebra not running for ${name}" >+ log_end_msg 1 >+ fi >+ fi >+} >+ >+zebra_status() >+{ >+ local name=$1 >+ >+ if is_zebra_running; then >+ log_daemon_msg "Zebra running for ${name}" >+ log_end_msg 0 >+ else >+ log_daemon_msg "Zebra not running for ${name}" >+ log_end_msg 3 >+ fi >+} >+ >+_check_and_fix_perms() >+{ >+ local name=$1 >+ >+ local files="/var/log/koha/${name}/zebra-output.log \ >+ /var/log/koha/${name}/zebra-error.log" >+ >+ for file in ${files} >+ do >+ if [ ! -e "${file}" ]; then >+ touch ${file} >+ fi >+ chown "${name}-koha":"${name}-koha" ${file} >+ done >+} >+ >+set_action() >+{ >+ if [ "$op" = "" ]; then >+ op=$1 >+ else >+ die "Error: only one action can be specified." >+ fi >+} >+ >+op="" >+verbose="no" >+ >+# Read command line parameters >+while [ $# -gt 0 ]; do >+ >+ case "$1" in >+ -h|--help) >+ usage ; exit 0 ;; >+ -v|--verbose) >+ verbose="yes" >+ shift ;; >+ --start) >+ set_action "start" >+ shift ;; >+ --stop) >+ set_action "stop" >+ shift ;; >+ --restart) >+ set_action "restart" >+ shift ;; >+ -*) >+ die "Error: invalid option switch ($1)" ;; >+ *) >+ # We expect the remaining stuff are the instance names >+ break ;; >+ esac >+ >+done >+ >+ZEBRA_DAEMON=$(which zebrasrv) >+ >+if [ $# -gt 0 ]; then >+ # We have at least one instance name >+ for name in "$@"; do >+ >+ if is_instance $name; then >+ >+ case $op in >+ "start") >+ start_zebra $name >+ ;; >+ "stop") >+ stop_zebra $name >+ ;; >+ "restart") >+ restart_zebra $name >+ ;; >+ "status") >+ zebra_status $name >+ esac >+ >+ else >+ if [ "$verbose" != "no" ]; then >+ log_daemon_msg "Error: Invalid instance name $name" >+ log_end_msg 1 >+ fi >+ fi >+ >+ done >+else >+ if [ "$verbose" != "no" ]; then >+ warn "Error: you must provide at least one instance name" >+ fi >+fi >+ >+exit 0 >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17467
:
56662
|
56663
|
56664
|
56665
|
56669
|
56693
|
58550
|
66420
|
66421
|
66422
|
66423
|
66424
|
66425
|
66426
|
68623
|
68624
|
68625
|
68626
|
68627
|
68628
|
68629