27347ca2f1fdd3417f7fd12c21bc784a6bc64441
[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 pidfile() {
26     echo "/var/run/pfixtools/$1.pid"
27 }
28
29 d_start() {
30     log_daemon_msg "Starting pidxtools"
31     if isyes "$SRSD_ENABLE" && test -x /usr/sbin/pfix-srsd; then
32         start_daemon -p /var/run/pfixtools/srsd.pid \
33             /usr/sbin/pfix-srsd $SRSD_OPTIONS       \
34                 -p /var/run/pfixtools/srsd.pid      \
35                 "$SRSD_DOMAIN" "$SRSD_SECRETS"
36         log_progress_msg "pidx-srsd"
37     fi
38     log_end_msg 0
39 }
40
41 d_stop() {
42     log_daemon_msg "Stopping pidxtools"
43     if isyes "$SRSD_ENABLE"; then
44         killproc -p /var/run/pfixtools/srsd.pid pfix-srsd
45         log_progress_msg "pidx-srsd"
46     fi
47     log_end_msg 0
48 }
49
50 case "$1" in
51     start)
52         d_start
53         ;;
54     stop)
55         d_stop
56         ;;
57     force-reload|restart)
58         d_stop
59         d_start
60         ;;
61     *)
62         echo "Usage: $0 {start|stop|restart|force-reload}" >&2
63         exit 1
64         ;;
65 esac
66
67 exit 0