prepare postfwd2 package

This commit is contained in:
Jan Wagner 2010-06-16 12:40:05 +00:00
parent c45f811ae2
commit c615938d8a
5 changed files with 227 additions and 0 deletions

15
debian/postfwd.default vendored Normal file
View file

@ -0,0 +1,15 @@
# Global options for postfwd(8).
# Set to '1' to enable startup (daemon mode)
STARTUP=0
# Config file
CONF=/etc/postfix/postfwd.cf
# IP where listen to
INET=127.0.0.1
# Port where listen to
PORT=10040
# run as user postfwd
RUNAS="postfw"
# Arguments passed on start (--daemon implied)
ARGS="--summary=600 --cache=600 --cache-rdomain-only --cache-no-size"

2
debian/postfwd.docs vendored Normal file
View file

@ -0,0 +1,2 @@
doc/postfwd.html
doc/postfwd.txt

100
debian/postfwd.init vendored Normal file
View file

@ -0,0 +1,100 @@
#! /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
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
sleep 1
$0 start
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0

57
debian/postfwd.postinst vendored Normal file
View file

@ -0,0 +1,57 @@
#!/bin/sh
# based on arpwatch.postinst: v11 2004/09/15 KELEMEN Peter <fuji@debian.org>
# postinst: v1 2006/01/12 Jan Wagner <waja@cyconet.org>
set -e
NUSER="postfw"
NGROUP="postfw"
NHOME="/var/lib/$NUSER"
NGECOS="postfwd user"
case "$1" in
configure)
# Take care of group.
if NGROUP_ENTRY=`getent group $NGROUP`; then
# group exists
:
else
# group does not exist yet
addgroup --quiet --system $NGROUP
fi
# Take care of user.
if NUSER_ENTRY=`getent passwd $NUSER`; then
# user exists
adduser --quiet $NUSER $NGROUP
#
else
# user does not exist yet
adduser --quiet --system \
--ingroup $NGROUP \
--gecos "$NGECOS" \
--home $NHOME \
--no-create-home \
--shell /bin/sh \
--disabled-login \
--disabled-password \
--shell /bin/false \
$NUSER
fi
# Set up home directory.
if [ -d $NHOME ]; then
chown -R ${NUSER}:${NGROUP} $NHOME
chmod -R o-rwX $NHOME
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#

53
debian/postfwd.postrm vendored Normal file
View file

@ -0,0 +1,53 @@
#!/bin/sh
# based on arpwatch.postrm: v2 2004/09/15 KELEMEN Peter <fuji@debian.org>
# postrm: v1 2006/10/12 Jan Wagner <waja@cyconet.org>
NUSER="postfw"
NGROUP="postfw"
set -e
case "$1" in
purge)
# find first and last SYSTEM_UID numbers
for LINE in `grep SYSTEM_UID /etc/adduser.conf | grep -v "^#"`; do
case $LINE in
FIRST_SYSTEM_UID*)
FIST_SYSTEM_UID=`echo $LINE | cut -f2 -d '='`
;;
LAST_SYSTEM_UID*)
LAST_SYSTEM_UID=`echo $LINE | cut -f2 -d '='`
;;
*)
;;
esac
done
# remove system account if necessary
if [ -n "$FIST_SYSTEM_UID" ] && [ -n "$LAST_SYSTEM_UID" ]; then
if USERID=`getent passwd $NUSER | cut -f 3 -d ':'`; then
if [ -n "$USERID" ]; then
if [ "$FIST_SYSTEM_UID" -le "$USERID" ] && \
[ "$USERID" -le "$LAST_SYSTEM_UID" ] && \
[ -x /usr/sbin/deluser ]; then
deluser --quiet $NUSER || true
# And then remove the group
GROUPID=`getent group $NGROUP | cut -f 3 -d ':'`
if [ -n "$GROUPID" ] && [ -x /usr/sbin/delgroup ] ; then
delgroup --quiet $NGROUP || true
fi
fi
fi
fi
fi
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#