Koha/debian/koha-common.init
Robin Sheat 3dc22e7fb2 Bug 9250 - [SIGNED-OFF] provide commands to manage the SIP server
This adds commands required to control the SIP server. These commands
are:
* koha-enable-sip - copies the SIP config to the sites directory
* koha-start-sip - starts the SIP server processes
* koha-stop-sip - stops the SIP server processes

It also calls these as appropriate from the koha-common init script.

To use:
1) sudo koha-enable-sip instancename
2) sudo vim /etc/koha/sites/instancename/SIPconfig.xml
   Do whatever is needed for your site's SIP configuration
3) sudo koha-start-sip instancename

To test:
1) Build packages with this patch
2) Ensure that sudo koha-start-sip instancename doesn't do anything
3) Run sudo koha-enable-sip instancename
4) Edit /etc/koha/sites/instancename/SIPconfig.xml if needed (probably
   not required for testing)
5) Run sudo koha-start-sip instancename
6) Note that the sip processes are now running
7) Run sudo koha-stop-sip instancename
8) Note that the sip processes have gone
9) Reboot your Koha server
10) Note that the sip processes are back

Sponsored-By: Waitaki District Council Libraries
Sponsored-By: South Taranaki District Council Libraries
Sponsored-By: Horowhenua District Council Libraries
Sponsored-By: Rangitikei District Council Libraries

Signed-off-by: Magnus Enger <magnus@enger.priv.no>
Works as advertised. koha-start-sip without a prior koha-enable-sip
does nothing. koha-enable-sip copies the SIP config file to the
instance directory. After koha-enable-sip, koha-start-sip and
koha-stop-sip works as expected. After a reboot, the SIP processes are
still running. I have not actually tested the SIP servers after they
have been started, but assume they work the same as always.
The man pages look good.

The new commands should also have been added to the man page for
koha-common. I'll do a followup for that.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2013-05-01 22:03:13 -04:00

127 lines
3 KiB
Bash
Executable file

#! /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()
{
# We insure all required directories exist, including disabled ones.
koha-create-dirs $(koha-list)
koha-start-zebra $(koha-list --enabled)
koha-start-sip $(koha-list --enabled)
}
#
# Function that stops the daemon/service
#
do_stop()
{
# We stop everything, including disabled ones.
koha-stop-zebra $(koha-list) || true
koha-stop-sip $(koha-list) || true
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
koha-restart-zebra $(koha-list --enabled)
koha-stop-sip $(koha-list) || true
koha-start-sip $(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
: