Mercurial > packages > rhel6 > postfwd
diff postfwd.init @ 0:e03652c59c7d
Initial revision
author | Guido Berhoerster <guido+packaging@berhoerster.name> |
---|---|
date | Wed, 09 Jan 2013 17:46:39 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/postfwd.init Wed Jan 09 17:46:39 2013 +0100 @@ -0,0 +1,119 @@ +#!/bin/sh +# +# postfwd - Postfix policy daemon +# +# chkconfig: - 20 80 +# description: Postfix policy daemon which combines complex postfix \ +# restrictions in a ruleset similar to those of the \ +# most firewalls + +### BEGIN INIT INFO +# Provides: postfwd +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: 0 1 2 3 4 5 6 +# Short-Description: postfwd Postfix policy daemon +# Description: postfwd Postfix policy daemon which combines complex postfix +# restrictions in a ruleset similar to those of the most firewalls +# +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +prog="postfwd" + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +POSTFWD_VARIANT="${POSTFWD_VARIANT:-postfwd}" + +exec="/usr/sbin/${POSTFWD_VARIANT}" +config=/etc/postfwd.cf +lockfile=/var/lock/subsys/$prog +pidfile=/var/run/$prog.pid + +ARGS="${ARGS:---proto=unix --port=/var/spool/postfix/postfwd/postfwd.socket}" + +start() { + [ -x $exec ] || exit 5 + echo -n $"Starting $prog: " + daemon $exec $ARGS --daemon --file=$config --user=postfwd --group=postfwd --pidfile=${pidfile} + retval=$? + echo + if [ $retval -eq 0 ]; then + touch $lockfile + return 0 + fi + return 1 +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p $pidfile $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + echo -n $"Reloading $prog: " + kill -HUP "$(head -1 "${pidfile}")" + retval=$? + echo + return $retval +} + +force_reload() { + restart +} + +rh_status() { + # run checks to determine if the service is running or use generic status + status $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac +exit $?