#!/bin/sh
#
# $OpenBSD: INSTALL,v 1.4 2003/02/17 16:14:34 avsm Exp $
#
# courier-imap installation to detect old-format config files

# exit on errors, use a sane path and install prefix
#
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}

COURIERCONF=/etc/courier-imap

do_notice()
{
    echo
    echo "+---------------"
    echo "| As of Courier-IMAP 1.3.0, configuration files have"
    echo "| been moved into /etc/courier-imap, and have a new"
    echo "| format."
    echo "| "
    echo "| The older format files have been detected on your"
    echo "| installation, so be sure to update these from the"
    echo "| ones in /usr/local/share/examples/courier-imap"
    echo "+---------------"
    echo
}

do_notice2()
{
    echo
    echo "+---------------"
    echo "| As of Courier-IMAP 1.3.5, we have switched to using the "
    echo "| authdaemon mechanism to handle authentication."
    echo "| "
    echo "| Please check your configuration files and update them "
    echo "| from /usr/local/share/examples/courier-imap"
    echo "+---------------"
    echo
}

# verify proper execution
#
if [ $# -ne 2 ]; then
    echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
    exit 1
fi

# Verify/process the command
#
case $2 in
    PRE-INSTALL)
	: nothing to pre-install for this port
	;;
    POST-INSTALL)
        if [ -f /etc/imapd.cnf -o -f /etc/imapd.config -o -f /etc/imapd-ssl.config ]; then
		do_notice
	fi
	if [ -d /etc/courier-imap -a ! -f /etc/courier-imap/authdaemonrc ]; then
		do_notice2
        fi
	;;
    *)
	echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
	exit 1
	;;
esac

exit 0
