#!/bin/sh
# $OpenBSD: INSTALL,v 1.1.1.1 2004/01/16 07:32:22 jolan Exp $
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
SYSCONFDIR=${SYSCONFDIR:-/etc}
CONFDIR=/etc/xfce4
DEFAULT=$CONFDIR/default.session
SHUTDOWN=$CONFDIR/shutdown.allow
XINITRC=$CONFDIR/xinitrc.xfce4-session
EXAMPLECONFDIR=$PREFIX/share/examples/xfce4-session
EXAMPLEDEFAULT=$EXAMPLECONFDIR/default.session
EXAMPLESHUTDOWN=$EXAMPLECONFDIR/shutdown.allow
EXAMPLEXINITRC=$EXAMPLECONFDIR/xinitrc.xfce4-session

do_confdir_install()
{
  install -d -o root -g wheel -m 755 $CONFDIR
}

do_install_conf()
{
  echo
  echo "+---------------"
  echo "| The $1 configuration files have been installed to the"
  echo "| following locations:"
  echo "|"
if [ ! -f $DEFAULT ]; then
  install -o root -g wheel -m 644 $EXAMPLEDEFAULT $DEFAULT
  echo "| $DEFAULT"
fi
if [ ! -f $SHUTDOWN ]; then
  install -o root -g wheel -m 644 $EXAMPLESHUTDOWN $SHUTDOWN
  echo "| $SHUTDOWN"
fi
if [ ! -f $XINITRC ]; then
  install -o root -g wheel -m 644 $EXAMPLEXINITRC $XINITRC
  echo "| $XINITRC"
fi
  echo "|"
  echo "| Please view these files and change them to suit your needs."
  echo "+---------------"
  echo
}

do_notice_default_conf()
{
if [ -f $DEFAULT ]; then
  echo
  echo "+---------------"
  echo "| The existing $1 configuration file at:"
  echo "|"
  echo "| $DEFAULT"
  echo "|"
  echo "| has NOT been changed.  You may want to compare it to"
  echo "| the current sample at:"
  echo "|"
  echo "| $EXAMPLEDEFAULT"
  echo "|"
  echo "| and update your configuration as needed."
  echo "+---------------"
  echo
fi
}

do_notice_shutdown_conf()
{
if [ -f $SHUTDOWN ]; then
  echo
  echo "+---------------"
  echo "| The existing $1 configuration file at:"
  echo "|"
  echo "| $SHUTDOWN"
  echo "|"
  echo "| has NOT been changed.  You may want to compare it to"
  echo "| the current sample at:"
  echo "|"
  echo "| $EXAMPLESHUTDOWN"
  echo "|"
  echo "| and update your configuration as needed."
  echo "+---------------"
  echo
fi
}

do_notice_xinitrc_conf()
{
if [ -f $XINITRC ]; then
  echo
  echo "+---------------"
  echo "| The existing $1 configuration file at:"
  echo "|"
  echo "| $XINITRC"
  echo "|"
  echo "| has NOT been changed.  You may want to compare it to"
  echo "| the current sample at:"
  echo "|"
  echo "| $EXAMPLEXINITRC"
  echo "|"
  echo "| and update your configuration as needed."
  echo "+---------------"
  echo
fi
}

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

case $2 in
    PRE-INSTALL)
        #
        ;;
    POST-INSTALL)
        if [ ! -d $CONFDIR ]; then
          do_confdir_install
        fi
        do_notice_default_conf $1
        do_notice_shutdown_conf $1
        do_notice_xinitrc_conf $1
        if [ ! -f $DEFAULT -o ! -f $SHUTDOWN -o ! -f $XINITRC ]; then
          do_install_conf $1
        fi
        ;;
    *)
        echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
        exit 1
        ;;
esac

exit 0
