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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
#! /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 <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
#
### BEGIN INIT INFO
# Provides: spf-milter spf-milter-python
# Required-Start: $local_fs $syslog $network $time
# Required-Stop: $local_fs $syslog $network
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: spf-milter-python
# Description: Python SPF Milter for Sendmail and Postfix
### END INIT INFO
prefix="/usr"
exec_prefix=${prefix}
sysconfdir="/etc/spf-milter-python"
bindir="${exec_prefix}/bin/"
RUNDIR="/var/run/spf-milter-python"
DAEMON=${bindir}/spfmilter
PATH=/sbin:/bin:/usr/sbin:/usr/bin:
NAME=spfmilter
DESC="Python SPF Milter"
USER=spf-milter-python
GROUP=spf-milter-python
SOCKET=$RUNDIR/spfmiltersock
test -x $DAEMON || exit 0
# Include spf-python-milter defaults if available
if [ -f /etc/default/spf-milter-python ] ; then
. /etc/default/spf-milter-python
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 --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 --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 --background --quiet --pidfile \
$RUNDIR/$NAME.pid --exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|force-reload|restart|}" >&2
exit 1
;;
esac
exit 0
|