#!/bin/sh
##
## Copyright (c) 2010-2026 The SquirrelMail Project Team
## Copyright (c) 2002-2010 Dave McMurtrie
##
## Licensed under the GNU GPL. For full terms see the file COPYING.
##
## This file is part of SquirrelMail IMAP Proxy.
##
##  Facility:
##
##	imapproxy.init
##
##  Abstract:
##
##	in.imapproxyd startup script
##
##  Authors:
##
##      Dave McMurtrie <davemcmurtrie@hotmail.com>
##
##  Version:
##
##      $Id: imapproxy-linux.init 15045 2026-01-15 10:56:28Z pdontthink $
##
##  Modification History:
##
##      $Log$
##
##      Revision 1.2  2002/12/19 21:48:07  dgm
##      Removed the notion of the startup script reading the config file and
##      passing arguments to the server process on startup.
##
##      Revision 1.1  2002/07/03 14:02:55  dgm
##      Initial revision
##
##
# Linux-style init file for squirrelmail-imap_proxy server daemon
#
# chkconfig: 2345 99 10
# description:  IMAP Proxy Daemon 
#
# processname: in.imapproxyd
# config: /etc/imapproxy.conf

Pgm=`/bin/basename $0`
PROXY_BIN=/usr/local/sbin/in.imapproxyd


start() {

    # make sure the executable exists.

    if [ ! -f $PROXY_BIN ]; then
	/bin/echo "$Pgm: $PROXY_BIN does not exist.  Not starting IMAP proxy server." 1>&2
	exit 1
    fi

    /bin/echo "$Pgm: Starting IMAP proxy server." 1>&2

    $PROXY_BIN

}


stop() {

    /bin/echo "$Pgm: Shutting down IMAP proxy server." 1>&2

    pkill -x in.imapproxyd

}


case $1 in

    'start')
	start
	;;



    'stop')
	stop
	;;


    'restart')
        stop
        start
        ;;


    *)
	/bin/echo "usage: $Pgm {start|stop|restart}" 1>&2

	exit 0

	;;

esac
