#!/bin/sh
# $OpenBSD: INSTALL,v 1.1 2004/02/03 21:25:50 espie Exp $
#
# Pre/post-installation setup of screen

# exit on errors, use a sane path and install prefix
#
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
CONFIG_DIR=/etc
SAMPLE_CONFIG_DIR=/usr/local/share/apps/kde-conf-sample

do_notice()
{
    echo
    echo "+---------------"
    echo "| The existing $1 configuration file, $2/$4,"
    echo "| has NOT been changed.  You may want to compare it to the"
    echo "| current sample file, $3/$4,"
    echo "| and update your configuration as needed."
    echo "+---------------"
    echo
}

do_install()
{
    install -o root -g wheel -m 644 $3/$4 $2/$4
    echo
    echo "+---------------"
    echo "| The $1 configuration file, $2/$4,"
    echo "| has been installed.  Please view this file and change"
    echo "| the configuration to meet your needs."
    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)
    	for i in xdg/menus/applications.menu
	    do
	    if [ -f ${CONFIG_DIR}/$i ]; then
		do_notice $1 ${CONFIG_DIR} ${SAMPLE_CONFIG_DIR} $i
	    else
		mkdir -p `dirname ${CONFIG_DIR}/$i`
		do_install $1 ${CONFIG_DIR} ${SAMPLE_CONFIG_DIR} $i
	    fi
	done
	;;
    *)
	echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
	exit 1
	;;
esac

exit 0
