#!/bin/sh

#
#   Stop script to stop the maildrop python process
#

# Set the maildrop main directory
reldir=`dirname $0`
if [ $reldir = "." ]; then
    reldir=`pwd`;
fi

MAILDROP_PACKAGE=`dirname $reldir`
CONFIG_HOME=`dirname $MAILDROP_PACKAGE`

# Source the config to find the location of the spool/var folder
. $CONFIG_HOME/config.py

# Where is the pid file?
if [ -z "$MAILDROP_VAR" ]
then
    MAILDROP_VAR=$MAILDROP_HOME/var
fi

if [ -z "$MAILDROP_PID_FILE" ]
then
    MAILDROP_PID_FILE=$MAILDROP_VAR/maildrop.pid
fi

# Kill the process
kill `cat $MAILDROP_PID_FILE`

# Remove the pid file
rm -f $MAILDROP_PID_FILE
