#!/bin/sh
# $OpenBSD: INSTALL,v 1.1.1.1 2003/05/29 11:09:46 sturm Exp $
#
# Pre/post-installation setup of sane-backends

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

# Function: tell the user what s/he needs to do to use the port just installed
#
do_notice()
{
    echo
    echo "+---------------"
    echo "| The directory ${ETCDIR} exists on your system.  It"
    echo "| has NOT been updated."
}

# Function: install the a2ps*.cfg where it is supposed to be.
#
do_install()
{
    install -d -g wheel -o root ${ETCDIR}
    ln -sn ${PREFIX}/share/apsfilter ${ETCDIR}/basedir
    echo
    echo "+---------------"
    echo "| To configure the $1 package, you have to run"
    echo "|"
    echo "|    ${ETCDIR}/basedir/SETUP"
    echo "|"
    echo "| as root."
}

do_end_notice()
{
    echo "|"
    echo "| Depending on your printer and what files you want to print,"
    echo "| $1 needs some software for conversion like ghostscript,"
    echo "| ImageMagick or teTeX. For details, see section 3.1 of"
    echo "| file:$PREFIX/share/doc/apsfilter/handbook.html"
    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 [ -d ${ETCDIR} ]; then
	    do_notice $1
	else
	    do_install $1
	fi
	do_end_notice $1
	;;
    *)
	echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
	exit 1
	;;
esac

exit 0

