Bug 13258 - Clicking the "show checkouts" button should return focus to the barcode...
[koha.git] / debian / koha-common.init
blob241aaa6aba3a6d943cf2061d4fa58a4c2f42f1fa
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
44 # Function that starts the daemon/service
46 do_start()
48 # We insure all required directories exist, including disabled ones.
49 koha-create-dirs $(koha-list)
50 koha-start-zebra $(koha-list --enabled)
51 koha-start-sip $(koha-list --enabled)
53 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
54 koha-indexer --start --quiet $(koha-list --enabled)
59 # Function that stops the daemon/service
61 do_stop()
63 # We stop everything, including disabled ones.
64 koha-stop-zebra $(koha-list) || true
65 koha-stop-sip $(koha-list) || true
67 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
68 koha-indexer --stop --quiet $(koha-list --enabled)
73 # Function that sends a SIGHUP to the daemon/service
75 do_reload() {
76 koha-restart-zebra $(koha-list --enabled)
77 koha-stop-sip $(koha-list) || true
78 koha-start-sip $(koha-list --enabled)
80 if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
81 koha-indexer --restart --quiet $(koha-list --enabled)
86 # Function that checks zebrasrv is running for the specified instance
88 is_zebra_running()
90 local instancename=$1
92 if daemon --name="$instancename-koha-zebra" \
93 --user="$instancename-koha.$instancename-koha" \
94 --running ; then
95 return 0
96 else
97 return 1
102 # Function that checks SIP server is running for the specified instance
104 is_sip_running()
106 local instancename=$1
108 if daemon --name="$instancename-koha-sip" \
109 --pidfiles="/var/run/koha/$instancename" \
110 --user="$instancename-koha.$instancename-koha" \
111 --running ; then
112 return 0
113 else
114 return 1
119 # Function that shows the status of the zebrasrv daemon for
120 # enabled instances
122 zebra_status()
124 for instance in $(koha-list --enabled); do
126 log_daemon_msg "Zebra server running for instace $instance"
128 if is_zebra_running $instance ; then
129 log_end_msg 0
130 else
131 log_end_msg 1
133 done
137 # Function that shows the status of the SIP server daemon for
138 # enabled instances
140 sip_status()
142 for instance in $(koha-list --enabled --sip); do
144 log_daemon_msg "SIP server running for instace $instance"
146 if is_sip_running $instance ; then
147 log_end_msg 0
148 else
149 log_end_msg 1
151 done
154 case "$1" in
155 start)
156 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
157 do_start
158 case "$?" in
159 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
160 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
161 esac
163 stop)
164 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
165 do_stop
166 case "$?" in
167 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
168 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
169 esac
171 restart|force-reload)
173 # If the "reload" option is implemented then remove the
174 # 'force-reload' alias
176 log_daemon_msg "Restarting $DESC" "$NAME"
177 do_stop
178 case "$?" in
180 do_start
181 case "$?" in
182 0) log_end_msg 0 ;;
183 *) log_end_msg 1 ;; # Failed to start
184 esac
187 # Failed to stop
188 log_end_msg 1
190 esac
192 status)
193 zebra_status
194 sip_status
197 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
198 exit 3
200 esac