Bug 5509 - use an XML parser to get values from config
[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     koha-start-zebra $(koha-list --enabled)
46 }
47
48 #
49 # Function that stops the daemon/service
50 #
51 do_stop()
52 {
53     # We stop everything, including disabled ones.
54     koha-stop-zebra $(koha-list) || true
55 }
56
57 #
58 # Function that sends a SIGHUP to the daemon/service
59 #
60 do_reload() {
61     koha-restart-zebra $(koha-list --enabled)
62 }
63
64 case "$1" in
65   start)
66         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
67         do_start
68         case "$?" in
69                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
70                 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
71         esac
72         ;;
73   stop)
74         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
75         do_stop
76         case "$?" in
77                 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
78                 *) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
79         esac
80         ;;
81 #  status)
82 #       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
83 #       ;;
84   #reload|force-reload)
85         #
86         # If do_reload() is not implemented then leave this commented out
87         # and leave 'force-reload' as an alias for 'restart'.
88         #
89         #log_daemon_msg "Reloading $DESC" "$NAME"
90         #do_reload
91         #log_end_msg $?
92         #;;
93   restart|force-reload)
94         #
95         # If the "reload" option is implemented then remove the
96         # 'force-reload' alias
97         #
98         log_daemon_msg "Restarting $DESC" "$NAME"
99         do_stop
100         case "$?" in
101           0)
102                 do_start
103                 case "$?" in
104                         0) log_end_msg 0 ;;
105                         *) log_end_msg 1 ;; # Failed to start
106                 esac
107                 ;;
108           *)
109                 # Failed to stop
110                 log_end_msg 1
111                 ;;
112         esac
113         ;;
114   *)
115         echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
116         #echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
117         exit 3
118         ;;
119 esac
120
121 :