Add scripts to start, stop, restart Zebra, and rebuild its indexes.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Lars Wirzenius 2010-05-25 13:44:20 +12:00 committed by Galen Charlton
parent 439989924d
commit 2e626be90c
10 changed files with 285 additions and 0 deletions

9
debian/koha-common.cron.d vendored Normal file
View file

@ -0,0 +1,9 @@
# /etc/cron.d/koha-common
#
# Call koha-rebuild-zebra for each enabled Koha instance, to make sure the
# Zebra indexes are up to date.
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)

121
debian/koha-common.init vendored Executable file
View file

@ -0,0 +1,121 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: koha-common
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Zebra server for each Koha instance
# Description: For each enabled Koha instance on this host,
# as listed by "koha-list --enabled", start a Zebra
# server (using koha-start-zebra).
### END INIT INFO
# Author: Lars Wirzenius <lars@catalyst.net.nz>
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Koha ILS"
NAME=daemonexecutablename
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--options args"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x /usr/sbin/koha-start-zebra ] || exit 0
# Read configuration variable file if it is present
# [ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
koha-start-zebra $(koha-list --enabled)
}
#
# Function that stops the daemon/service
#
do_stop()
{
# We stop everything, including disabled ones.
koha-stop-zebra $(koha-list) || true
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
koha-restart-zebra $(koha-list --enabled)
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
# status)
# status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
# ;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0)
do_start
case "$?" in
0) log_end_msg 0 ;;
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
#echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View file

@ -165,6 +165,8 @@ generate_config_file zebra-authorities-site.cfg.in \
"/etc/koha/sites/$name/zebra-authorities.cfg"
generate_config_file zebra-authorities-dom-site.cfg.in \
"/etc/koha/sites/$name/zebra-authorities-dom.cfg"
generate_config_file zebra.passwd.in \
"/etc/koha/sites/$name/zebra.passwd"
# Upgrade the database schema, just in case the dump was from an old version.

38
debian/scripts/koha-rebuild-zebra vendored Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
#
# koha-rebuild-zebra -- Rebuild the Zebra database for a Koha instance.
# 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
if [ "$1" = --full ]
then
opts="-r"
shift
else
opts="-z"
fi
for name in "$@"
do
sudo -u "$name-koha" \
env PERL5LIB=/usr/share/koha/lib \
KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \
/usr/share/koha/bin/migration_tools/rebuild_zebra.pl -b -a $opts
done

View file

@ -35,6 +35,7 @@ eof
rm "/etc/koha/sites/$name/zebra-biblios.cfg"
rm "/etc/koha/sites/$name/zebra-authorities.cfg"
rm "/etc/koha/sites/$name/zebra-authorities-dom.cfg"
rm "/etc/koha/sites/$name/zebra.passwd"
rmdir "/etc/koha/sites/$name"
rm -r "/var/lock/koha/$name"
rm -r "/var/log/koha/$name"

38
debian/scripts/koha-restart-zebra vendored Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
#
# koha-restart-zebra -- Restart Zebra for named Koha instandes
# 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
for name in "$@"
do
echo "Restarting Zebra server for $name"
daemon \
--name="$name-koha-zebra" \
--errlog="/var/log/koha/$name/zebra-error.log" \
--stdout="/var/log/koha/$name/zebra.log" \
--output="/var/log/koha/$name/zebra-output.log" \
--verbose=1 \
--respawn \
--delay=30 \
--user="$name-koha.$name-koha" \
--restart \
-- \
zebrasrv \
-v none,fatal,warn \
-f "/etc/koha/sites/$name/koha-conf.xml"
done

View file

@ -74,6 +74,7 @@ CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd';
GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser';
FLUSH PRIVILEGES;
eof
koha-rebuild-zebra --full "$name"
# Restart Apache.

37
debian/scripts/koha-start-zebra vendored Executable file
View file

@ -0,0 +1,37 @@
#!/bin/sh
#
# koha-start-zebra -- Start Zebra for named Koha instandes
# 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
for name in "$@"
do
echo "Starting Zebra server for $name"
daemon \
--name="$name-koha-zebra" \
--errlog="/var/log/koha/$name/zebra-error.log" \
--stdout="/var/log/koha/$name/zebra.log" \
--output="/var/log/koha/$name/zebra-output.log" \
--verbose=1 \
--respawn \
--delay=30 \
--user="$name-koha.$name-koha" \
-- \
zebrasrv \
-v none,fatal,warn \
-f "/etc/koha/sites/$name/koha-conf.xml"
done

37
debian/scripts/koha-stop-zebra vendored Executable file
View file

@ -0,0 +1,37 @@
#!/bin/sh
#
# koha-stop-zebra -- Stop Zebra for named Koha instandes
# 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
for name in "$@"
do
echo "Stopping Zebra server for $name"
daemon \
--name="$name-koha-zebra" \
--errlog="/var/log/koha/$name/zebra-error.log" \
--stdout="/var/log/koha/$name/zebra.log" \
--output="/var/log/koha/$name/zebra-output.log" \
--verbose=1 \
--respawn \
--delay=30 \
--user="$name-koha.$name-koha" \
--stop \
-- \
zebrasrv \
-f "/etc/koha/sites/$name/koha-conf.xml"
done

1
debian/templates/zebra.passwd.in vendored Normal file
View file

@ -0,0 +1 @@
kohauser:__ZEBRA_PASS__