diff --git a/CHANGES b/CHANGES index 33db311..95a5079 100644 --- a/CHANGES +++ b/CHANGES @@ -9,4 +9,4 @@ 0.9.2 UNRELEASED - Improved package requirements definition - - Added systemd unit file + - Added systemd unit file and (untested) sysv init file diff --git a/README b/README index 6859689..1fea45a 100644 --- a/README +++ b/README @@ -13,6 +13,12 @@ default is a feature: python setup.py install --single-version-externally-managed --record=/dev/null +Both a systemd unit file and a sysv init file are provided. Both make +assumptions about defaults being used, e.g. if a non-standard pidfile name is +used, they will need to be updated. The sysv init file is Debian specific and +untested, since the developers are not using sysv init. Feedback/patches +welcome. + WARNING: This is an alpha grade release to support interoperability testing with Ed25519 signatures and basic functionality. It is known to be incomplete and not suitable for general use. diff --git a/TODO b/TODO index c09eb5b..982b82f 100644 --- a/TODO +++ b/TODO @@ -15,10 +15,13 @@ UMask implemented UserID implemented verified DKIM 'a' in AR implemented verified +0.9.2 (Alpha) +dkimpy-milter.service implemented verified +sysv init implemented +remove PidFile on stop implemented verified + 0.9.5 (Beta) dkimpy-milter.8 -dkimpy-milter.service -remove PidFile on stop AuthservID Canonicalization Diagnostics diff --git a/setup.py b/setup.py index 11571a4..4caf3db 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,9 @@ setup( include_package_data=True, data_files=[(os.path.join('share', 'man', 'man5'), ['man/dkimpy-milter.conf.5']), ('etc', ['etc/dkimpy-milter.conf']), - (os.path.join('/lib', 'systemd', 'system'), ['system/dkimpy-milter.service'])], + (os.path.join('/lib', 'systemd', 'system'), + ['system/dkimpy-milter.service']),(os.path.join('/etc', 'init.d'), + ['system/dkimpy-milter.init'])], install_requires = ['dkimpy>=0.7', 'pymilter', 'authres>=1.0.2', 'nacl'], zip_safe = False, diff --git a/system/dkimpy-milter.init b/system/dkimpy-milter.init new file mode 100644 index 0000000..e24bc93 --- /dev/null +++ b/system/dkimpy-milter.init @@ -0,0 +1,133 @@ +#! /bin/sh +# +# skeleton example file to build /etc/init.d/ scripts. +# This file should be used to construct scripts for /etc/init.d. +# +# Written by Miquel van Smoorenburg . +# Modified for Debian +# by Ian Murdock . +# +# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl +# +### BEGIN INIT INFO +# Provides: dkim-milter dkim-milter-python dkimpy-milter +# Required-Start: $remote_fs $syslog $network $time +# Required-Stop: $remote_fs $syslog $network +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: dkimpy-milter +# Description: Python DKIM Milter for Sendmail and Postfix +### END INIT INFO +prefix="/usr" +exec_prefix=${prefix} +sysconfdir="/etc/dkimpy-milter" +bindir="${exec_prefix}/bin/" +RUNDIR="/var/run/dkimpy-milter" +DAEMON=${bindir}/dkimpy-milter +PATH=/sbin:/bin:/usr/sbin:/usr/bin: +NAME=dkimpy-milter +DESC="Python DKIM Milter" +USER=dkimpy-milter +GROUP=dkimpy-milter +SOCKET=$RUNDIR/dkimpy-milter.pid + +test -x $DAEMON || exit 0 + +# Include dkimpy-python defaults if available +# Typically not used +if [ -f /etc/default/dkimpy-milter ] ; then + . /etc/default/dkimpy-milter +fi + +set -e + +. /lib/lsb/init-functions + +case "$1" in + start) + echo -n "Starting $DESC: " + # Create the run directory if it doesn't exist + if [ ! -d $RUNDIR ]; then + install -o $USER -g $GROUP -m 755 -d $RUNDIR || return 2 + fi + + # Clean up stale sockets + if [ -f $RUNDIR/$NAME.pid ]; then + pid=`cat $RUNDIR/$NAME.pid` + if ! ps -C $DAEMON -s $pid >/dev/null; then + rm $RUNDIR/$NAME.pid + # UNIX sockets may be specified with or without the + # local: prefix; handle both + t=`echo $SOCKET | cut -d: -f1` + s=`echo $SOCKET | cut -d: -f2` + if [ -e $s -a -S $s ]; then + if [ "$t" = "$s" -o "$t" = "local" ]; then + rm $s + fi + fi + fi + fi + + start-stop-daemon --start --chuid $USER --background --quiet --pidfile \ + $RUNDIR/$NAME.pid --exec $DAEMON + echo "$NAME." + ;; + stop) + echo -n "Stopping $DESC: " + if [ -f $RUNDIR/$NAME.pid ]; then + start-stop-daemon --stop --pidfile $RUNDIR/$NAME.pid + rm $RUNDIR/$NAME.pid + #echo $SOCKET + if [ -e $SOCKET ]; then + rm $SOCKET + fi + fi + echo "$NAME." + ;; + force-reload) + echo -n "Force reloading $DESC: " + if [ -f $RUNDIR/$NAME.pid ]; then + start-stop-daemon --stop --pidfile $RUNDIR/$NAME.pid + rm $RUNDIR/$NAME.pid + #echo $SOCKET + if [ -e $SOCKET ]; then + rm $SOCKET + fi + fi + sleep 1 + start-stop-daemon --start --chuid $USER --background --quiet --pidfile \ + $RUNDIR/$NAME.pid --exec $DAEMON + echo "$NAME." + ;; + restart) + echo "Restarting $DESC: " + echo -n "Stopping $DESC: " + if [ -f $RUNDIR/$NAME.pid ]; then + start-stop-daemon --stop --pidfile $RUNDIR/$NAME.pid + rm $RUNDIR/$NAME.pid + #echo $SOCKET + if [ -e $SOCKET ]; then + rm $SOCKET + fi + fi + echo "$NAME." + sleep 1 + echo -n "Starting $DESC: " + start-stop-daemon --start --chuid $USER --background --quiet --pidfile \ + $RUNDIR/$NAME.pid --exec $DAEMON + echo "$NAME." + ;; + status) + status_of_proc -p /var/run/dkimpy-milter/dkimpy-milter.pid /usr/bin/dkimpy-milter dkimpy-milter + ;; + + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|force-reload|restart|}" >&2 + exit 1 + ;; +esac + +exit 0