#!/bin/sh
# $OpenBSD: INSTALL,v 1.5 2000/09/28 01:05:21 brad 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_FILE=/etc/screenrc
SAMPLE_CONFIG_DIR=$PREFIX/share/examples/screen

do_notice()
{
    echo
    echo "+---------------"
    echo "| The file $CONFIG_FILE exists on your system.  It has"
    echo "| NOT been updated.  Please look at the file "
    echo "| $SAMPLE_CONFIG_DIR/screenrc-sample"
    echo "| and add any desired (but missing) entries into your"
    echo "| current $CONFIG_FILE"
}

do_install()
{
    install -o root -g wheel -m 644 $SAMPLE_CONFIG_DIR/screenrc-sample $CONFIG_FILE
    echo
    echo "+---------------"
    echo "| The file $CONFIG_FILE has been created on your system."
    echo "| You may want to verify/edit its contents"
}

do_screencap()
{
    echo "|"
    echo "| The file $SAMPLE_CONFIG_DIR/screencap contains a"
    echo "| termcap like description of the screen virtual terminal."
    echo "| You may use it to update your terminal database."
    echo "| See termcap(5)."
    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 [ -e $CONFIG_FILE ]; then
	    do_notice $1
	else
	    do_install $1
	fi
	do_screencap $1
	;;
    *)
	echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
	exit 1
	;;
esac

exit 0
