pfix-srsd: add a -I option
[apps/pfixtools.git] / debian / pfixtools.init
1 #! /bin/sh -e
2 ### BEGIN INIT INFO
3 # Provides:             pfixtools
4 # Required-Start:       $syslog $network
5 # Required-Stop:        $syslog $network
6 # Default-Start:        2 3 4 5
7 # Default-Stop:         0 1 6
8 # Short-Description:    Start the pfixtools daemons
9 ### END INIT INFO
10
11 PATH=/sbin:/bin:/usr/sbin:/usr/bin
12
13  . /lib/lsb/init-functions
14 test -r /etc/default/pfixtools && . /etc/default/pfixtools
15
16 mkdir -p /var/run/pfixtools &>/dev/null
17
18 isyes() {
19     case "$1" in
20         [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) true;;
21         *) false;;
22     esac
23 }
24
25 d_start() {
26     log_daemon_msg "Starting pidxtools"
27     if isyes "$SRSD_ENABLE" && test -x /usr/sbin/pfix-srsd; then
28         start_daemon -p /var/run/pfixtools/srsd.pid \
29             /usr/sbin/pfix-srsd $SRSD_OPTIONS       \
30                 -p /var/run/pfixtools/srsd.pid      \
31                 "$SRSD_DOMAIN" "$SRSD_SECRETS"
32         log_progress_msg "pidx-srsd"
33     fi
34     log_end_msg 0
35 }
36
37 d_stop() {
38     log_daemon_msg "Stopping pidxtools"
39     if isyes "$SRSD_ENABLE"; then
40         killproc -p /var/run/pfixtools/srsd.pid pfix-srsd
41         log_progress_msg "pidx-srsd"
42     fi
43     log_end_msg 0
44 }
45
46 case "$1" in
47     start)
48         d_start
49         ;;
50     stop)
51         d_stop
52         ;;
53     force-reload|restart)
54         d_stop
55         d_start
56         ;;
57     *)
58         echo "Usage: $0 {start|stop|restart|force-reload}" >&2
59         exit 1
60         ;;
61 esac
62
63 exit 0