~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/postfwd

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
#               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
 
3
#               Modified for Debian
 
4
#               by Ian Murdock <imurdock@gnu.ai.mit.edu>.
 
5
#
 
6
# Version:      @(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
 
7
# /etc/init.d/postfwd: v1 2008/03/12 Jan Wagner <waja@cyconet.org>
 
8
 
 
9
### BEGIN INIT INFO
 
10
# Provides: postfwd
 
11
# Required-Start: $local_fs $network $remote_fs $syslog
 
12
# Required-Stop: $local_fs $network $remote_fs $syslog
 
13
# Default-Start:  2 3 4 5
 
14
# Default-Stop: 0 1 6
 
15
# Short-Description: start and stop the postfw daemon
 
16
# Description: a Perl policy daemon for the Postfix MTA
 
17
### END INIT INFO
 
18
 
 
19
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
20
NAME=postfwd
 
21
DAEMON=/usr/sbin/${NAME}
 
22
PIDFILE=/var/run/$NAME.pid
 
23
DESC=postfwd
 
24
 
 
25
. /lib/lsb/init-functions
 
26
 
 
27
test -x $DAEMON || exit 0
 
28
 
 
29
not_configured () {
 
30
        echo "#### WARNING ####"
 
31
        echo "${NAME} won't be started/stopped unless it is configured."
 
32
        echo "If you want to start ${NAME} as daemon, see /etc/default/${NAME}."
 
33
        echo "#################"
 
34
        exit 0
 
35
}
 
36
 
 
37
no_configfile () {
 
38
        echo "#### WARNING ####"
 
39
        echo "${NAME} won't be started/stopped unless a rules file is provided at $CONF."
 
40
        echo "#################"
 
41
        exit 0
 
42
}
 
43
 
 
44
# check if postfwd is configured or not
 
45
if [ -f "/etc/default/$NAME" ]
 
46
then
 
47
        . /etc/default/$NAME
 
48
        if [ "$STARTUP" != "1" ]
 
49
        then
 
50
                not_configured
 
51
        fi
 
52
else
 
53
        not_configured
 
54
fi
 
55
 
 
56
# check if rules file is there
 
57
if [ ! -f $CONF ]
 
58
then
 
59
        no_configfile
 
60
fi
 
61
 
 
62
# Check whether we have to drop privileges.
 
63
if [ -n "$RUNAS" ]
 
64
then
 
65
        if ! getent passwd "$RUNAS" >/dev/null; then
 
66
                RUNAS=""
 
67
        fi
 
68
fi
 
69
 
 
70
set -e
 
71
 
 
72
case "$1" in
 
73
  start)
 
74
        echo -n "Starting $DESC: "
 
75
        start-stop-daemon --start --quiet \
 
76
                --name ${RUNAS} \
 
77
                --exec $DAEMON -- ${ARGS} --daemon --file=${CONF} --interface=${INET} --port=${PORT} --user=${RUNAS} --group=${RUNAS} --pidfile=$PIDFILE
 
78
        echo "$NAME."
 
79
        ;;
 
80
  stop)
 
81
        echo -n "Stopping $DESC: "
 
82
        start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE && rm -rf $PIDFILE
 
83
        echo "$NAME."
 
84
        ;;
 
85
  reload)
 
86
        echo "Reloading $DESC configuration files."
 
87
                kill -HUP $(cat $PIDFILE)
 
88
        ;;
 
89
  restart|force-reload)
 
90
        echo -n "Restarting $DESC (incl. cache): "
 
91
                $0 stop > /dev/null
 
92
                sleep 1
 
93
                $0 start > /dev/null
 
94
        echo "$NAME."
 
95
        ;;
 
96
  *)
 
97
        N=/etc/init.d/$NAME
 
98
        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
 
99
        exit 1
 
100
        ;;
 
101
esac
 
102
 
 
103
exit 0