Tomas Cohen Arazi
213fbdc5b4
Removed unused stuff, added a new config file /etc/default/koha-common to control the init script behaviour. Currently is only a stub. The config file could be put on /etc/sysconfig on RedHat and friends. The init script should work them too. Added a TODO comment regarding the 'status' switch. To test: - Apply the patch on master, build your own packages and install. - The init script should continue to work as expected. (it can be tested replacing the /etc/init.d/koha-common file with debian/koha-common.init on a packages install). - The absence of the /etc/default/koha-common file should not prevent the init script from working. Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Robin Sheat <robin@catalyst.net.nz> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
122 lines
2.9 KiB
Bash
Executable file
122 lines
2.9 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="koha-common"
|
|
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
|
|
if [ -r /etc/default/$NAME ]; then
|
|
# Debian / Ubuntu
|
|
. /etc/default/$NAME
|
|
elif [ -r /etc/sysconfig/$NAME ]; then
|
|
# RedHat / SuSE
|
|
. /etc/sysconfig/$NAME
|
|
fi
|
|
|
|
# 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
|
|
;;
|
|
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
|
|
;;
|
|
# TODO: Implement this. It should check every daemon is running
|
|
# status)
|
|
# status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
|
# ;;
|
|
*)
|
|
#echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
|
|
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
|
exit 3
|
|
;;
|
|
esac
|
|
|
|
:
|