Bug 20434: Update UNIMARC framework - auth (SNG)
[koha.git] / debian / koha-common.init
blobaeb526f2b66fe8f941099e4c7caa901fb2e13fff
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: koha-common
4 # Required-Start: $remote_fs memcached
5 # Required-Stop: $remote_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Start required services for each Koha instance
9 # Description: For each enabled Koha instance on this host,
10 # if enabled, start:
11 # - a Zebra server (using koha-zebra)
12 # - a Plack server (using koha-plack)
13 # - a SIP server (using koha-sip)
14 ### END INIT INFO
16 # Author: Lars Wirzenius <lars@catalyst.net.nz>
18 # Do NOT "set -e"
20 # PATH should only include /usr/* if it runs after the mountnfs.sh script
21 PATH=/sbin:/usr/sbin:/bin:/usr/bin
22 DESC="Koha ILS"
23 NAME="koha-common"
24 SCRIPTNAME=/etc/init.d/$NAME
26 # Exit if the package is not installed
27 [ -x /usr/sbin/koha-zebra ] || exit 0
29 # Read configuration variable file if it is present
30 if [ -r /etc/default/$NAME ]; then
31 # Debian / Ubuntu
32 . /etc/default/$NAME
33 elif [ -r /etc/sysconfig/$NAME ]; then
34 # RedHat / SuSE
35 . /etc/sysconfig/$NAME
38 # Load the VERBOSE setting and other rcS variables
39 . /lib/init/vars.sh
41 # Define LSB log_* functions.
42 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
43 . /lib/lsb/init-functions
45 # include helper functions
46 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
47 . "/usr/share/koha/bin/koha-functions.sh"
48 else
49 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
50 exit 1
54 # Function that starts the daemon/service
56 do_start()
58 # We insure all required directories exist, including disabled ones.
59 koha-create-dirs $(koha-list)
60 koha-zebra --start $(koha-list --enabled)
61 koha-sip --start $(koha-list --enabled --sip)
62 koha-plack --start $(koha-list --enabled --plack)
63 koha-z3950-responder --start $(koha-list --enabled --z3950)
65 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
66 koha-indexer --start --quiet $(koha-list --enabled)
71 # Function that stops the daemon/service
73 do_stop()
75 # We stop everything, including disabled ones.
76 koha-zebra --stop $(koha-list) || true
77 koha-sip --stop $(koha-list --sip)
78 koha-plack --stop --quiet $(koha-list --enabled --plack)
80 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
81 koha-indexer --stop --quiet $(koha-list --enabled)
86 # Function that sends a SIGHUP to the daemon/service
88 do_reload() {
89 koha-zebra --restart $(koha-list --enabled)
90 koha-sip --restart $(koha-list --enabled --sip)
91 koha-plack --restart --quiet $(koha-list --enabled --plack)
93 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
94 koha-indexer --restart --quiet $(koha-list --enabled)
99 # Function that shows the status of the zebrasrv daemon for
100 # enabled instances
102 zebra_status()
104 for instance in $(koha-list --enabled); do
106 log_daemon_msg "Zebra server running for instance $instance"
108 if is_zebra_running $instance ; then
109 log_end_msg 0
110 else
111 log_end_msg 1
113 done
117 # Function that shows the status of the SIP server daemon for
118 # enabled instances
120 sip_status()
122 for instance in $(koha-list --enabled --sip); do
124 log_daemon_msg "SIP server running for instance $instance"
126 if is_sip_running $instance ; then
127 log_end_msg 0
128 else
129 log_end_msg 1
131 done
135 # Function that shows the status of the Plack server daemon for
136 # enabled instances
138 plack_status()
140 for instance in $(koha-list --enabled --plack); do
142 log_daemon_msg "Plack server running for instance ${instance}"
144 if is_plack_running $instance ; then
145 log_end_msg 0
146 else
147 log_end_msg 1
149 done
153 # Function that shows the status of the Z39.50/SRU server daemon for
154 # enabled instances
156 z3950_status()
158 for instance in $(koha-list --enabled --z3950); do
160 log_daemon_msg "Z39.50/SRU daemon running for instance ${instance}"
162 if is_z3950_running $instance ; then
163 log_end_msg 0
164 else
165 log_end_msg 1
167 done
170 case "$1" in
171 start)
172 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
173 do_start
174 case "$?" in
175 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
176 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
177 esac
179 stop)
180 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
181 do_stop
182 case "$?" in
183 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
184 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
185 esac
187 restart|force-reload)
189 # If the "reload" option is implemented then remove the
190 # 'force-reload' alias
192 log_daemon_msg "Restarting $DESC" "$NAME"
193 do_stop
194 case "$?" in
196 do_start
197 case "$?" in
198 0) log_end_msg 0 ;;
199 *) log_end_msg 1 ;; # Failed to start
200 esac
203 # Failed to stop
204 log_end_msg 1
206 esac
208 status)
209 zebra_status
210 sip_status
211 plack_status
212 z3950_status
215 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
216 exit 3
218 esac