141 lines
2.8 KiB
Bash
Executable File
141 lines
2.8 KiB
Bash
Executable File
#! /bin/sh
|
|
### BEGIN INIT INFO
|
|
# Provides: koha-plack
|
|
# Required-Start: $remote_fs
|
|
# Required-Stop: $remote_fs
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Start starman server for Koha plack
|
|
# Description: For each enabled Koha instance on this host,
|
|
# start a starman server for using plack
|
|
### END INIT INFO
|
|
|
|
# Author: Baptiste Costes
|
|
|
|
# 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 Plack"
|
|
NAME="koha-plack"
|
|
SCRIPTNAME=/etc/init.d/$NAME
|
|
|
|
# Exit if the package is not installed
|
|
[ -x /usr/sbin/koha-plack ] || 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-plack --start koha
|
|
}
|
|
|
|
#
|
|
# Function that stops the daemon/service
|
|
#
|
|
do_stop()
|
|
{
|
|
koha-plack --stop --quiet koha
|
|
}
|
|
|
|
#
|
|
# Function that sends a SIGHUP to the daemon/service
|
|
#
|
|
do_reload() {
|
|
koha-plack --restart --quiet koha
|
|
}
|
|
|
|
#
|
|
# Function that shows the status of the Plack server daemon for
|
|
# enabled instances
|
|
#
|
|
plack_status()
|
|
{
|
|
log_daemon_msg "Plack server running for instance koha"
|
|
|
|
if is_plack_running "koha" ; then
|
|
log_end_msg 0
|
|
else
|
|
log_end_msg 1
|
|
fi
|
|
}
|
|
|
|
is_plack_running()
|
|
{
|
|
local instancename=$1
|
|
|
|
if start-stop-daemon --pidfile "/var/run/koha/plack.pid" \
|
|
--status ; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
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
|
|
;;
|
|
status)
|
|
plack_status
|
|
;;
|
|
*)
|
|
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
|
|
exit 3
|
|
;;
|
|
esac
|
|
|
|
:
|