Mercurial > packages > rhel6 > postfwd
comparison postfwd.init @ 0:e03652c59c7d
Initial revision
author | Guido Berhoerster <guido+packaging@berhoerster.name> |
---|---|
date | Wed, 09 Jan 2013 17:46:39 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e03652c59c7d |
---|---|
1 #!/bin/sh | |
2 # | |
3 # postfwd - Postfix policy daemon | |
4 # | |
5 # chkconfig: - 20 80 | |
6 # description: Postfix policy daemon which combines complex postfix \ | |
7 # restrictions in a ruleset similar to those of the \ | |
8 # most firewalls | |
9 | |
10 ### BEGIN INIT INFO | |
11 # Provides: postfwd | |
12 # Required-Start: $local_fs $network $remote_fs | |
13 # Required-Stop: $local_fs $network $remote_fs | |
14 # Should-Start: | |
15 # Should-Stop: | |
16 # Default-Start: | |
17 # Default-Stop: 0 1 2 3 4 5 6 | |
18 # Short-Description: postfwd Postfix policy daemon | |
19 # Description: postfwd Postfix policy daemon which combines complex postfix | |
20 # restrictions in a ruleset similar to those of the most firewalls | |
21 # | |
22 ### END INIT INFO | |
23 | |
24 # Source function library. | |
25 . /etc/rc.d/init.d/functions | |
26 | |
27 prog="postfwd" | |
28 | |
29 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog | |
30 | |
31 POSTFWD_VARIANT="${POSTFWD_VARIANT:-postfwd}" | |
32 | |
33 exec="/usr/sbin/${POSTFWD_VARIANT}" | |
34 config=/etc/postfwd.cf | |
35 lockfile=/var/lock/subsys/$prog | |
36 pidfile=/var/run/$prog.pid | |
37 | |
38 ARGS="${ARGS:---proto=unix --port=/var/spool/postfix/postfwd/postfwd.socket}" | |
39 | |
40 start() { | |
41 [ -x $exec ] || exit 5 | |
42 echo -n $"Starting $prog: " | |
43 daemon $exec $ARGS --daemon --file=$config --user=postfwd --group=postfwd --pidfile=${pidfile} | |
44 retval=$? | |
45 echo | |
46 if [ $retval -eq 0 ]; then | |
47 touch $lockfile | |
48 return 0 | |
49 fi | |
50 return 1 | |
51 } | |
52 | |
53 stop() { | |
54 echo -n $"Stopping $prog: " | |
55 killproc -p $pidfile $prog | |
56 retval=$? | |
57 echo | |
58 [ $retval -eq 0 ] && rm -f $lockfile | |
59 return $retval | |
60 } | |
61 | |
62 restart() { | |
63 stop | |
64 start | |
65 } | |
66 | |
67 reload() { | |
68 echo -n $"Reloading $prog: " | |
69 kill -HUP "$(head -1 "${pidfile}")" | |
70 retval=$? | |
71 echo | |
72 return $retval | |
73 } | |
74 | |
75 force_reload() { | |
76 restart | |
77 } | |
78 | |
79 rh_status() { | |
80 # run checks to determine if the service is running or use generic status | |
81 status $prog | |
82 } | |
83 | |
84 rh_status_q() { | |
85 rh_status >/dev/null 2>&1 | |
86 } | |
87 | |
88 | |
89 case "$1" in | |
90 start) | |
91 rh_status_q && exit 0 | |
92 $1 | |
93 ;; | |
94 stop) | |
95 rh_status_q || exit 0 | |
96 $1 | |
97 ;; | |
98 restart) | |
99 $1 | |
100 ;; | |
101 reload) | |
102 rh_status_q || exit 7 | |
103 $1 | |
104 ;; | |
105 force-reload) | |
106 force_reload | |
107 ;; | |
108 status) | |
109 rh_status | |
110 ;; | |
111 condrestart|try-restart) | |
112 rh_status_q || exit 0 | |
113 restart | |
114 ;; | |
115 *) | |
116 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" | |
117 exit 2 | |
118 esac | |
119 exit $? |