forked from Koha-Community/Koha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkoha-core.init
executable file
·226 lines (198 loc) · 5.43 KB
/
koha-core.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#! /bin/sh
### BEGIN INIT INFO
# Provides: koha-core
# Required-Start: $remote_fs memcached
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start required services for each Koha instance
# Description: For each enabled Koha instance on this host,
# if enabled, start:
# - a Zebra server (using koha-zebra)
# - a Plack server (using koha-plack)
# - a SIP server (using koha-sip)
# - a Z3950 server (using koha-z3950-responder)
### END INIT INFO
# Author: Lars Wirzenius <[email protected]>
# 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-core"
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x /usr/sbin/koha-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
# include helper functions
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
. "/usr/share/koha/bin/koha-functions.sh"
else
echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
exit 1
fi
#
# Function that starts the daemon/service
#
do_start()
{
# We insure all required directories exist, including disabled ones.
koha-create-dirs $(koha-list)
## koha-zebra --start $(koha-list --enabled)
## koha-sip --start $(koha-list --enabled --sip)
## koha-plack --start $(koha-list --enabled --plack)
## koha-z3950-responder --start --quiet $(koha-list --enabled --z3950)
## koha-worker --start $(koha-list --enabled)
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
koha-indexer --start --quiet $(koha-list --enabled)
fi
}
#
# Function that stops the daemon/service
#
do_stop()
{
# We stop everything, including disabled ones.
## koha-zebra --stop $(koha-list) || true
## koha-sip --stop $(koha-list --sip)
## koha-plack --stop --quiet $(koha-list --enabled --plack)
## koha-z3950-responder --stop --quiet $(koha-list --enabled --z3950)
## koha-worker --stop --quiet $(koha-list --enabled)
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
koha-indexer --stop --quiet $(koha-list --enabled)
fi
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
## koha-zebra --restart $(koha-list --enabled)
## koha-sip --restart $(koha-list --enabled --sip)
## koha-plack --restart --quiet $(koha-list --enabled --plack)
## koha-z3950-responder --restart --quiet $(koha-list --enabled --z3950)
## koha-worker --restart --quiet $(koha-list --enabled)
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
koha-indexer --restart --quiet $(koha-list --enabled)
fi
}
#
# Function that shows the status of the zebrasrv daemon for
# enabled instances
#
zebra_status()
{
for instance in $(koha-list --enabled); do
log_daemon_msg "Zebra server running for instance $instance"
if is_zebra_running $instance ; then
log_end_msg 0
else
log_end_msg 1
fi
done
}
#
# Function that shows the status of the SIP server daemon for
# enabled instances
#
sip_status()
{
for instance in $(koha-list --enabled --sip); do
log_daemon_msg "SIP server running for instance $instance"
if is_sip_running $instance ; then
log_end_msg 0
else
log_end_msg 1
fi
done
}
#
# Function that shows the status of the Plack server daemon for
# enabled instances
#
plack_status()
{
for instance in $(koha-list --enabled --plack); do
log_daemon_msg "Plack server running for instance ${instance}"
if is_plack_running $instance ; then
log_end_msg 0
else
log_end_msg 1
fi
done
}
#
# Function that shows the status of the Z39.50/SRU server daemon for
# enabled instances
#
z3950_status()
{
for instance in $(koha-list --enabled --z3950); do
log_daemon_msg "Z39.50/SRU daemon running for instance ${instance}"
if is_z3950_running $instance ; then
log_end_msg 0
else
log_end_msg 1
fi
done
}
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)
zebra_status
sip_status
plack_status
z3950_status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
exit 3
;;
esac
: