Bug 6516 - Make borrowernumber of staff user configurable in koha-create
[koha.git] / debian / koha-common.init
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
13
14 # Author: Lars Wirzenius <lars@catalyst.net.nz>
15
16 # Do NOT "set -e"
17
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=daemonexecutablename
22 DAEMON=/usr/sbin/$NAME
23 DAEMON_ARGS="--options args"
24 PIDFILE=/var/run/$NAME.pid
25 SCRIPTNAME=/etc/init.d/$NAME
26
27 # Exit if the package is not installed
28 [ -x /usr/sbin/koha-start-zebra ] || exit 0
29
30 # Read configuration variable file if it is present
31 # [ -r /etc/default/$NAME ] && . /etc/default/$NAME
32
33 # Load the VERBOSE setting and other rcS variables
34 . /lib/init/vars.sh
35
36 # Define LSB log_* functions.
37 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
38 . /lib/lsb/init-functions
39
40 #
41 # Function that starts the daemon/service
42 #
43 do_start()
44 {
45     # We insure all required directories exist, including disabled ones.
46     koha-create-dirs $(koha-list)
47     koha-start-zebra $(koha-list --enabled)
48 }
49
50 #
51 # Function that stops the daemon/service
52 #
53 do_stop()
54 {
55     # We stop everything, including disabled ones.
56     koha-stop-zebra $(koha-list) || true
57 }
58
59 #
60 # Function that sends a SIGHUP to the daemon/service
61 #
62 do_reload() {
63     koha-restart-zebra $(koha-list --enabled)
64 }
65
66 case "$1" in
67   start)
68         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
69         do_start
70         case "$?" in
71                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
72                 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
73         esac
74         ;;
75   stop)
76         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
77         do_stop
78         case "$?" in
79                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
80                 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
81         esac
82         ;;
83 #  status)
84 #       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
85 #       ;;
86   #reload|force-reload)
87         #
88         # If do_reload() is not implemented then leave this commented out
89         # and leave 'force-reload' as an alias for 'restart'.
90         #
91         #log_daemon_msg "Reloading $DESC" "$NAME"
92         #do_reload
93         #log_end_msg $?
94         #;;
95   restart|force-reload)
96         #
97         # If the "reload" option is implemented then remove the
98         # 'force-reload' alias
99         #
100         log_daemon_msg "Restarting $DESC" "$NAME"
101         do_stop
102         case "$?" in
103           0)
104                 do_start
105                 case "$?" in
106                         0) log_end_msg 0 ;;
107                         *) log_end_msg 1 ;; # Failed to start
108                 esac
109                 ;;
110           *)
111                 # Failed to stop
112                 log_end_msg 1
113                 ;;
114         esac
115         ;;
116   *)
117         echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
118         #echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
119         exit 3
120         ;;
121 esac
122
123 :