File: postfwd.init

package info (click to toggle)
postfwd 1.35-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,552 kB
  • ctags: 327
  • sloc: perl: 5,574; sh: 191; makefile: 39
file content (103 lines) | stat: -rw-r--r-- 2,463 bytes parent folder | download | duplicates (4)
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
#! /bin/sh
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
# /etc/init.d/postfwd: v1 2008/03/12 Jan Wagner <waja@cyconet.org>

### BEGIN INIT INFO
# Provides: postfwd
# Required-Start: $local_fs $network $remote_fs $syslog
# Required-Stop: $local_fs $network $remote_fs $syslog
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop the postfw daemon
# Description: a Perl policy daemon for the Postfix MTA
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=postfwd
DAEMON=/usr/sbin/${NAME}
PIDFILE=/var/run/$NAME.pid
DESC=postfwd

. /lib/lsb/init-functions

test -x $DAEMON || exit 0

not_configured () {
        echo "#### WARNING ####"
        echo "${NAME} won't be started/stopped unless it is configured."
        echo "If you want to start ${NAME} as daemon, see /etc/default/${NAME}."
        echo "#################"
        exit 0
}

no_configfile () {
	echo "#### WARNING ####"
	echo "${NAME} won't be started/stopped unless a rules file is provided at $CONF."
	echo "#################"
	exit 0
}

# check if postfwd is configured or not
if [ -f "/etc/default/$NAME" ]
then
        . /etc/default/$NAME
        if [ "$STARTUP" != "1" ]
        then
                not_configured
        fi
else
        not_configured
fi

# check if rules file is there
if [ ! -f $CONF ]
then
	no_configfile
fi

# Check whether we have to drop privileges.
if [ -n "$RUNAS" ]
then
        if ! getent passwd "$RUNAS" >/dev/null; then
                RUNAS=""
        fi
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet \
                --name ${RUNAS} \
                --exec $DAEMON -- ${ARGS} --daemon --file=${CONF} --interface=${INET} --port=${PORT} --user=${RUNAS} --group=${RUNAS} --pidfile=$PIDFILE
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE && rm -rf $PIDFILE
        echo "$NAME."
	;;
  reload)
	echo "Reloading $DESC configuration files."
		kill -HUP $(cat $PIDFILE)
	;;
  restart|force-reload)
	echo -n "Restarting $DESC (incl. cache): "
	        $0 stop > /dev/null
        	sleep 1
	        $0 start > /dev/null
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0