Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
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. |
9 |
# |
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. |
14 |
# |
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>. |
17 |
|
18 |
### BEGIN INIT INFO |
19 |
# Provides: koha-sru-server-$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-sru-server for $DBNAME |
26 |
### END INIT INFO |
27 |
|
28 |
. /lib/lsb/init-functions |
29 |
|
30 |
USER=__KOHA_USER__ |
31 |
GROUP=__KOHA_GROUP__ |
32 |
DBNAME=__DB_NAME__ |
33 |
NAME=koha-sru-server-$DBNAME |
34 |
PORT=9998 |
35 |
LOGDIR=__LOG_DIR__ |
36 |
PERL5LIB=__PERL_MODULE_DIR__ |
37 |
KOHA_CONFDIR=__KOHA_CONF_DIR__ |
38 |
KOHA_CONF=$KOHA_CONFDIR/koha-conf.xml |
39 |
SRU_CONFDIR=$KOHA_CONFDIR/sru_server |
40 |
DANCER_CONFDIR=$SRU_CONFDIR |
41 |
ERRLOG=$LOGDIR/koha-sru-server.err |
42 |
STDOUT=$LOGDIR/koha-sru-server.log |
43 |
OUTPUT=$LOGDIR/koha-sru-server-output.log |
44 |
|
45 |
export KOHA_CONF |
46 |
export PERL5LIB |
47 |
export DANCER_CONFDIR |
48 |
|
49 |
SRUSERVER="/usr/bin/plackup --server Starman --port $PORT $PERL5LIB/misc/sru_server.pl" |
50 |
SRUSERVER_OPTS="" |
51 |
|
52 |
DAEMONOPTS="--name=$NAME \ |
53 |
--errlog=$ERRLOG \ |
54 |
--stdout=$STDOUT \ |
55 |
--output=$OUTPUT \ |
56 |
--verbose=1 --respawn --delay=30" |
57 |
|
58 |
USER="--user=$USER.$GROUP" |
59 |
|
60 |
|
61 |
case "$1" in |
62 |
start) |
63 |
log_daemon_msg "Starting Koha SRU server ($DBNAME)" |
64 |
if daemon $DAEMONOPTS $USER -- $SRUSERVER $SRUSERVER_OPTS; then |
65 |
log_end_msg 0 |
66 |
else |
67 |
log_end_msg 1 |
68 |
fi |
69 |
;; |
70 |
stop) |
71 |
log_daemon_msg "Stopping Koha SRU server ($DBNAME)" |
72 |
if daemon $DAEMONOPTS $USER --stop -- $SRUSERVER $SRUSERVER_OPTS; then |
73 |
log_end_msg 0 |
74 |
else |
75 |
log_end_msg 1 |
76 |
fi |
77 |
;; |
78 |
restart) |
79 |
log_daemon_msg "Restarting the Koha SRU server ($DBNAME)" |
80 |
if daemon $DAEMONOPTS $USER --restart -- $SRUSERVER $SRUSERVER_OPTS; then |
81 |
log_end_msg 0 |
82 |
else |
83 |
log_end_msg 1 |
84 |
fi |
85 |
;; |
86 |
*) |
87 |
log_success_msg "Usage: /etc/init.d/$NAME {start|stop|restart}" |
88 |
exit 1 |
89 |
;; |
90 |
esac |