Bug 18931: (followup) Tidy text
[koha.git] / debian / koha-common.init
blobb461056a7e4f6b406805bc9fb371b7e40db80f7f
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: koha-common
4 # Required-Start: $remote_fs
5 # Required-Stop: $remote_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Start Zebra server for each Koha instance
9 # Description: For each enabled Koha instance on this host,
10 # as listed by "koha-list --enabled", start a Zebra
11 # server (using koha-start-zebra).
12 ### END INIT INFO
14 # Author: Lars Wirzenius <lars@catalyst.net.nz>
16 # Do NOT "set -e"
18 # PATH should only include /usr/* if it runs after the mountnfs.sh script
19 PATH=/sbin:/usr/sbin:/bin:/usr/bin
20 DESC="Koha ILS"
21 NAME="koha-common"
22 SCRIPTNAME=/etc/init.d/$NAME
24 # Exit if the package is not installed
25 [ -x /usr/sbin/koha-start-zebra ] || exit 0
27 # Read configuration variable file if it is present
28 if [ -r /etc/default/$NAME ]; then
29 # Debian / Ubuntu
30 . /etc/default/$NAME
31 elif [ -r /etc/sysconfig/$NAME ]; then
32 # RedHat / SuSE
33 . /etc/sysconfig/$NAME
36 # Load the VERBOSE setting and other rcS variables
37 . /lib/init/vars.sh
39 # Define LSB log_* functions.
40 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
41 . /lib/lsb/init-functions
43 # include helper functions
44 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
45 . "/usr/share/koha/bin/koha-functions.sh"
46 else
47 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
48 exit 1
52 # Function that starts the daemon/service
54 do_start()
56 # We insure all required directories exist, including disabled ones.
57 koha-create-dirs $(koha-list)
58 koha-start-zebra $(koha-list --enabled)
59 koha-start-sip $(koha-list --enabled)
60 koha-plack --start $(koha-list --enabled --plack)
62 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
63 koha-indexer --start --quiet $(koha-list --enabled)
68 # Function that stops the daemon/service
70 do_stop()
72 # We stop everything, including disabled ones.
73 koha-stop-zebra $(koha-list) || true
74 koha-stop-sip $(koha-list) || true
75 koha-plack --stop --quiet $(koha-list --enabled --plack)
77 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
78 koha-indexer --stop --quiet $(koha-list --enabled)
83 # Function that sends a SIGHUP to the daemon/service
85 do_reload() {
86 koha-restart-zebra $(koha-list --enabled)
87 koha-stop-sip $(koha-list) || true
88 koha-start-sip $(koha-list --enabled)
89 koha-plack --restart --quiet $(koha-list --enabled --plack)
91 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
92 koha-indexer --restart --quiet $(koha-list --enabled)
97 # Function that shows the status of the zebrasrv daemon for
98 # enabled instances
100 zebra_status()
102 for instance in $(koha-list --enabled); do
104 log_daemon_msg "Zebra server running for instance $instance"
106 if is_zebra_running $instance ; then
107 log_end_msg 0
108 else
109 log_end_msg 1
111 done
115 # Function that shows the status of the SIP server daemon for
116 # enabled instances
118 sip_status()
120 for instance in $(koha-list --enabled --sip); do
122 log_daemon_msg "SIP server running for instance $instance"
124 if is_sip_running $instance ; then
125 log_end_msg 0
126 else
127 log_end_msg 1
129 done
133 # Function that shows the status of the Plack server daemon for
134 # enabled instances
136 plack_status()
138 for instance in $(koha-list --enabled --plack); do
140 log_daemon_msg "Plack server running for instance ${instance}"
142 if is_plack_running $instance ; then
143 log_end_msg 0
144 else
145 log_end_msg 1
147 done
150 case "$1" in
151 start)
152 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
153 do_start
154 case "$?" in
155 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
156 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
157 esac
159 stop)
160 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
161 do_stop
162 case "$?" in
163 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
164 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
165 esac
167 restart|force-reload)
169 # If the "reload" option is implemented then remove the
170 # 'force-reload' alias
172 log_daemon_msg "Restarting $DESC" "$NAME"
173 do_stop
174 case "$?" in
176 do_start
177 case "$?" in
178 0) log_end_msg 0 ;;
179 *) log_end_msg 1 ;; # Failed to start
180 esac
183 # Failed to stop
184 log_end_msg 1
186 esac
188 status)
189 zebra_status
190 sip_status
191 plack_status
194 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
195 exit 3
197 esac