#!/bin/sh
# $OpenBSD: INSTALL,v 1.2 1999/04/10 07:14:56 marc Exp $
#
# Pre/post-installation setup of enscript

set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PREFIX:-/usr/local}
CONFIG_FILE=/etc/enscript.cfg
CONFIG_SAMPLE=${PREFIX}/lib/enscript.cfg-sample

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

# install the configuration files unless an existing configuration
# is found in which case warn the user that it may need to be
# updated.
#
do_configuration()
{
    if [ ! -r ${CONFIG_SAMPLE} ]; then
	echo "-- Can't find configuration sample file: ${CONFIG_SAMPLE}" >&2
	exit 1
    fi

    if [ -r ${CONFIG_FILE} ]; then
        echo
        echo "+---------------"
	echo "| The file ${CONFIG_FILE} exists.  Your existing configuration"
	echo "| has not been changed.  You MAY need to update your"
	echo "| configuration.  See the current configuration sample file"
	echo "| ${CONFIG_SAMPLE}."
        echo "+---------------"
        echo
    else
	cp ${CONFIG_SAMPLE} ${CONFIG_FILE}
    fi
}

case $2 in
    PRE-INSTALL)
	: nothing to pre-install for this port
	;;
    POST-INSTALL)
	do_configuration
	;;
esac

exit 0

