aboutsummaryrefslogtreecommitdiff
path: root/network/postgrey/rc.postgrey
blob: 5c33151085e6ff04eef88df2c8d87273a2b7da91 (plain)
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
#!/bin/bash

. /etc/postgrey.conf || exit 1

postgrey_start() {
  echo "Starting postgrey milter:  /usr/bin/postgrey -d --inet=$PORT --pidfile=$PIDFILE --user=$USER --group=$GROUP --dbdir=/var/lib/postgrey --hostname=$HOST"
  mkdir -p $(dirname $PIDFILE)
  chown ${USER}:${GROUP} $(dirname $PIDFILE)

  /usr/bin/postgrey -d \
                    --inet=$PORT \
                    --pidfile=$PIDFILE \
                    --user=$USER --group=$GROUP \
                    --dbdir=/var/lib/postgrey \
                    --hostname=$HOST
}

postgrey_stop() {
  if [ -e $PIDFILE ]; then
    echo "Stopping postgrey milter..."
    kill $(cat $PIDFILE) 1>/dev/null
  fi
}

case "$1" in
'start')
  postgrey_start
  ;;
'stop')
  postgrey_stop
  ;;
'restart')
  postgrey_stop
  sleep 2
  postgrey_start
  ;;
*)
  echo "usage $0 start|stop|restart"
  ;;
esac