#!/bin/sh
# $OpenBSD: INSTALL,v 1.1 1999/04/08 22:41:17 marc Exp $
#
# Pre/post-installation setup for metamail

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


# Function: tell the user what s/he needs to do to use the port just installed
#
do_notice()
{
    echo
    echo "+---------------"
    echo "| The file ${MAILCAP} exists on your system.  Please look"
    echo "| at the file ${PREFIX}/lib/metamail/mailcap"
    echo "| and add any desired (but missing) entries into your"
    echo "| ${MAILCAP}"
    echo "+---------------"
    echo
}

# Function: copy the metamail mailcap to /etc
#
do_install()
{
    cp ${PREFIX}/lib/metamail/mailcap /etc
    echo
    echo "+---------------"
    echo "| The file ${MAILCAP} has been created on your system."
    echo "| Other MIME capable programs may also use this file."
    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 ${MAILCAP} ]; then
	    do_notice $1
	else
	    do_install $1
	fi
	;;
    *)
	echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
	exit 1
	;;
esac

exit 0
