Sorry about the barrage of new bug reports. Here's a new init.d script that
will close this bug. Since imapproxy forks away without creating a pid file,
it is now necessary to require that foreground_mode be set to yes in
/etc/imapproxy.conf. Please update the example imapproxy.conf to reflect
this.

This script also fixes a problem I noticed where starting imapproxy from an
SSH session would cause the SSH client to hang on logout.

-- 
Jacob Elder
#! /bin/sh
# Initfile for imapproxy
#
# 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 <[EMAIL PROTECTED]>.
#               Modified for Debian GNU/Linux
#               by Ian Murdock <[EMAIL PROTECTED]>.
#
# Version:      @(#)skeleton  1.8  03-Mar-1998  [EMAIL PROTECTED]
# Customized for Debian imapproxy by Jacob Elder <[EMAIL PROTECTED]>

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/imapproxyd
CONF=/etc/imapproxy.conf
ARGS="-f $CONF"
NAME="imapproxy"
DESC="IMAP proxy"
PIDFILE="/var/run/$NAME.pid"

test -f $DAEMON || exit 0

if ! grep '^foreground_mode yes' $CONF 2>&1 > /dev/null ; then
        echo $NAME: foreground_mode must be enabled in $CONF.
        exit 1
fi

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
        rm -f $PIDFILE
        start-stop-daemon --start --quiet --background --make-pidfile 
--pidfile=$PIDFILE --exec $DAEMON -- $ARGS
        sleep 1
        if grep $DAEMON /proc/`cat $PIDFILE`/cmdline 2>&1 >/dev/null ; then
                echo "$NAME."
        else
                echo Failed to start $NAME. Check logs for details.
        fi
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile=$PIDFILE --exec $DAEMON -- 
$ARGS
        echo "$NAME."
        
        ;;

  restart|force-reload)
        echo -n "Restarting $DESC: "
        $0 stop
        sleep 1
        $0 start
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Reply via email to