Bug 15896 [QA Followup] - Remove use of Carp::Always
[koha.git] / misc / bin / koha-index-daemon-ctl.sh
blob1c8f4fef4a220225e1059f6ac8eece5e6d3f8dfd
1 #!/bin/sh
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 ### BEGIN INIT INFO
19 # Provides: koha-index-daemon-$DBNAME
20 # Required-Start: $local_fs $syslog
21 # Required-Stop: $local_fs $syslog
22 # Default-Start: 2 3 4 5
23 # Default-Stop: 0 1 6
24 # X-Interactive: false
25 # Short-Description: Start/stop koha-index-daemon for $DBNAME
26 ### END INIT INFO
28 . /lib/lsb/init-functions
30 USER=__KOHA_USER__
31 GROUP=__KOHA_GROUP__
32 DBNAME=__DB_NAME__
33 NAME=koha-index-daemon-$DBNAME
34 LOGDIR=__LOG_DIR__
35 PERL5LIB=__PERL_MODULE_DIR__
36 KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml
37 ERRLOG=$LOGDIR/koha-index-daemon.err
38 STDOUT=$LOGDIR/koha-index-daemon.log
39 OUTPUT=$LOGDIR/koha-index-daemon-output.log
41 export KOHA_CONF
42 export PERL5LIB
44 INDEXDAEMON="koha-index-daemon"
45 INDEXDAEMON_OPTS="--timeout 30 --conf $KOHA_CONF \
46 --directory /var/tmp/koha-index-daemon-$DBNAME"
48 DAEMONOPTS="--name=$NAME \
49 --errlog=$ERRLOG \
50 --stdout=$STDOUT \
51 --output=$OUTPUT \
52 --verbose=1 --respawn --delay=30"
54 USER="--user=$USER.$GROUP"
57 case "$1" in
58 start)
59 log_daemon_msg "Starting Koha indexing daemon ($DBNAME)"
60 if daemon $DAEMONOPTS $USER -- $INDEXDAEMON $INDEXDAEMON_OPTS; then
61 log_end_msg 0
62 else
63 log_end_msg 1
66 stop)
67 log_daemon_msg "Stopping Koha indexing daemon ($DBNAME)"
68 if daemon $DAEMONOPTS $USER --stop -- $INDEXDAEMON $INDEXDAEMON_OPTS; then
69 log_end_msg 0
70 else
71 log_end_msg 1
74 restart)
75 log_daemon_msg "Restarting the Koha indexing daemon ($DBNAME)"
76 if daemon $DAEMONOPTS $USER --restart -- $INDEXDAEMON $INDEXDAEMON_OPTS; then
77 log_end_msg 0
78 else
79 log_end_msg 1
83 log_success_msg "Usage: /etc/init.d/$NAME {start|stop|restart}"
84 exit 1
86 esac