3
# This initscript was created by Ulises Vitulli <dererk@debian.org> for mailavenger
5
# Start/stop the mailavenger daemon
7
# Provides: mailavenger
8
# Required-Start: $syslog $remote_fs $time
9
# Required-Stop: $syslog $remote_fs $time
10
# Default-Start: 2 3 4 5
12
# Short-Description: mailavenger SMTP filter server
13
# Description: This daemon handles the status of the MailAvenger stmpd
16
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17
DAEMON=/usr/sbin/asmtpd
24
test -x $DAEMON || exit 0
26
. /lib/lsb/init-functions
30
# This returns 0 if the daemon is running, returns 1 otherwise.
31
start-stop-daemon --start --test --exec $DAEMON -- $DAEMON_OPTS >/dev/null 2>&1
36
log_begin_msg "Starting $NAME daemon..."
38
# Check if user has acknowledged to have configured Mail Avenger.
40
if [ -f /etc/default/mailavenger ] ; then
41
. /etc/default/mailavenger
44
if [ "$RUN_DAEMON" = "no" ]; then
45
log_failure_msg "DAEMON DISABLED, Launch aborted."
46
log_failure_msg "Please check /usr/share/doc/mailavenger/README.Debian for a quick start."
50
if ! daemon_status ; then
51
log_begin_msg "Already running."
57
if [ ! -d "/var/run/$NAME" ]; then
58
mkdir -p /var/run/$NAME
59
chown $USER:nogroup /var/run/$NAME
62
start-stop-daemon --start --oknodo --pidfile /var/run/$NAME/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
64
if ! pidof $DAEMON > /var/run/$NAME/$NAME.pid; then
65
log_begin_msg "Oops, something went wront. CHECK SYSLOG!"
71
log_begin_msg "Stopping $NAME daemon..."
72
start-stop-daemon --stop --oknodo --pidfile /var/run/$NAME/$NAME.pid --exec $DAEMON
74
rm /var/run/$NAME/$NAME.pid >/dev/null 2>&1
78
if ! daemon_status; then
79
log_begin_msg "$NAME is RUNNING using process id `cat /var/run/$NAME/$NAME.pid`."
82
log_failure_msg "$NAME is STOPPED!"
86
if ! daemon_status; then
87
log_begin_msg "Reloading $NAME configuration..."
88
start-stop-daemon --stop --signal HUP --pidfile /var/run/$NAME/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS && \
89
log_end_msg 0 && echo "done." || log_end_msg 3
92
log_failure_msg "$NAME is STOPPED!"
102
log_success_msg "Usage: /etc/init.d/$NAME {start|stop|status|force-reload|restart}"