Debian Codegraph @

debian/qpsmtpd.init

raw
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides: qpsmtpd
5 # Required-Start: $local_fs $remote_fs $network $named
6 # Should-Start: $syslog $mail-transport-agent clamav-daemon spamassassin
7 # Required-Stop: $local_fs $remote_fs $syslog
8 # Default-Start: 2 3 4 5
9 # Default-Stop: 0 1 6
10 # Short-Description: Start and stop the qpsmtpd SMTP daemon
11 # Description: Qpsmtpd is an SMTP daemon which acts as a frontend
12 # for a mail transport system.
13 ### END INIT INFO
14
15 set -e
16
17 . /lib/lsb/init-functions
18
19 PATH=/sbin:/usr/sbin:/bin:/usr/bin
20
21
22 PORT="25"
23 RUNAS="qpsmtpd"
24 NICE=""
25 INTERFACES=""
26 LISTEN=""
27 ENABLED="false"
28 SERVER="forkserver"
29 EXTRA_ARGS=""
30
31 [ -f "/etc/qpsmtpd/debconf-settings" ] && . "/etc/qpsmtpd/debconf-settings"
32
33 [ -x "/usr/bin/qpsmtpd-$SERVER" ] || exit 0
34
35 [ "$ENABLED" = "true" -o "$ENABLED" = "1" ] || exit 0
36
37 if [ "x$INTERFACES" != "x" ] ; then
38 LISTEN=`echo "$INTERFACES" | \
39 perl -pe 's/(\S+)/--listen-address $1/g'`
40 fi
41
42 qpsmtpd_start()
43 {
44 export QPSMTPD_CONFIG="/etc/qpsmtpd"
45 if [ ! -d "/var/run/qpsmtpd" ] ; then
46 mkdir -p /var/run/qpsmtpd
47 chown $RUNAS:adm /var/run/qpsmtpd
48 chmod 2755 /var/run/qpsmtpd
49 fi
50 start-stop-daemon --quiet --start \
51 --exec /usr/bin/qpsmtpd-$SERVER -- \
52 --port $PORT --user $RUNAS \
53 --pid-file /var/run/qpsmtpd/qpsmtpd.pid \
54 $LISTEN --detach $EXTRA_ARGS
55 }
56
57 qpsmtpd_stop()
58 {
59 # qpsmtpd is a perl script, and s-s-d's --exec option
60 # would look at the interpreter path rather than the script. More
61 # seriously, however, --exec compares devices/inodes rather than
62 # executable paths, so --exec will break every time the perl package
63 # is upgraded (see Debian Bug#337942). So, --exec isn't used at all.
64 start-stop-daemon --quiet --stop --retry 4 --oknodo \
65 --pidfile /var/run/qpsmtpd/qpsmtpd.pid \
66 --user "$RUNAS"
67 }
68
69 qpsmtpd_status()
70 {
71 echo -n "Checking status of qpsmtpd: "
72 if [ -f "/var/run/qpsmtpd/qpsmtpd.pid" ] ; then
73 if start-stop-daemon --quiet --stop --signal 0 \
74 --pidfile /var/run/qpsmtpd/qpsmtpd.pid ; then
75 echo "running"
76 exit 0
77 else
78 echo "not running, stale PID file"
79 exit 1
80 fi
81 else
82 echo "not running"
83 exit 3
84 fi
85 }
86
87 case "$1" in
88 start)
89 echo -n "Starting qpsmtpd: "
90 qpsmtpd_start
91 echo "qpsmtpd-$SERVER."
92 ;;
93 stop)
94 echo -n "Stopping qpsmtpd: "
95 qpsmtpd_stop
96 echo "qpsmtpd-$SERVER."
97 ;;
98 restart|reload|force-reload)
99 qpsmtpd_stop
100 qpsmtpd_start
101 ;;
102 status)
103 qpsmtpd_status
104 ;;
105 *)
106 echo "usage: $0 {start|stop|restart|status}"
107 exit 1
108 ;;
109 esac
110
111 exit 0
112
113