File: rc-debian.sh.in

package info (click to toggle)
milter-greylist 4.5.11-1.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,828 kB
  • ctags: 1,830
  • sloc: ansic: 17,049; yacc: 2,158; lex: 585; sh: 536; makefile: 156
file content (128 lines) | stat: -rw-r--r-- 2,946 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/sh

# Greylist init script
# July 2004
# BERTRAND Joël
#
### BEGIN INIT INFO
# Provides:                 milter-greylist
# Required-Start:    $local_fs $named $remote_fs $syslog
# Required-Stop:     $local_fs $remote_fs
# Should-Start:             sendmail
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Script to start/stop the greylist-milter
# Description: another spam-defense service
### END INIT INFO

. /lib/lsb/init-functions

# Based on skeleton by Miquel van Smoorenburg and Ian Murdock

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=@SBINDIR@/milter-greylist
NAME=greylist
SNAME=greylist
DESC="Greylist Mail Filter Daemon"
PIDFILE="/var/run/$NAME.pid"
PNAME="milter-greylist"
USER="@USER@"
SOCKET=/var/run/milter-greylist/milter-greylist.sock


[ -x $DAEMON ] || DAEMON=@BINDIR@/milter-greylist
[ -x $DAEMON ] || exit 0


export TMPDIR=/tmp
# Apparently people have trouble if this isn't explicitly set...

ENABLED=0
OPTIONS=""
NICE=

test -f /etc/default/milter-greylist && . /etc/default/milter-greylist

DOPTIONS="-P $PIDFILE -u $USER -p $SOCKET"

if [ "$ENABLED" = "0" ]; then
    echo "$DESC: disabled, see /etc/default/milter-greylist"
    exit 0
fi

if ! getent passwd | grep -q "^greylist:"; then
  echo "$0: greylist user does not exist. Aborting" >&2
  exit 1
fi
if ! getent group | grep -q "^greylist:" ; then
  echo "$0: greylist group does not exist. Aborting" >&2
  exit 1
fi

if [ ! -d /var/run/$PNAME ]; then
  mkdir /var/run/$PNAME
  chown greylist:greylist /var/run/$PNAME
  chmod 755 /var/run/$PNAME
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --pidfile $PIDFILE --name $PNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS
	echo "$NAME."
	;;

  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --name $PNAME --oknodo
	echo "$NAME."
	;;

  restart|force-reload)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --name $PNAME \
	    --retry 5 --oknodo
	start-stop-daemon --start --pidfile $PIDFILE --name $PNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS

	echo "$NAME."
	;;

  reload)
	echo -n "Checking config: "
	if sudo -c "$DAEMON -c" $USER 2>&1 |grep -v 'config .* okay$' |grep . >&2
	then
	  echo "failed.  Quitting with error, no action taken."
	  exit 1
	else
	  echo "passed."
	fi
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --name $PNAME \
	    --retry 5 --oknodo
	start-stop-daemon --start --pidfile $PIDFILE --name $PNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS

	echo "$NAME."
	;;

  status)
  	PID=`pidof $DAEMON`
	if [ x$PID = x ]; then
	  echo "$DAEMON is not running"
	else
	  echo "$DESC is running with pid[$PID]"
	fi
	;;
  *)
	N=/etc/init.d/$SNAME
	echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0