#!/bin/sh

# $Id: installProfile,v 1.2 1997/07/08 09:31:14 svein Exp $

if test "$quiet" -eq 0
then
echo "Editing xite_profile." 1>&2
fi

if test "$buildOnly" -eq 0
then
  if test -f xite_profile
  then
    echo "Moving existing xite_profile to xite_profile.old." 1>&2
    mv xite_profile xite_profile.old
  fi

  awk -f $edprofile bin=$XITE_BIN_DEST man=$XITE_MAN_DEST \
    doc=$XITE_DOC_DEST home=$XITE_HOME \
    xite_hosttype=$XITE_HOSTTYPE \
    xite_profile.tmpl > xite_profile
else
  if test -f xite_profile
  then
    echo "Backup copy of existing xite_profile put in xite_profile.bak." 1>&2
    cp xite_profile xite_profile.bak
  fi

  if test -s xite_profile.bak
  then
    infile=xite_profile.bak
  else
    infile=xite_profile.tmpl
  fi

  awk -f $edprofile bin=$XITE_BIN_DEST man=$XITE_MAN_DEST \
    doc=$XITE_DOC_DEST home=$XITE_HOME \
    home=$XITE_HOME xite_hosttype=$XITE_HOSTTYPE \
    $infile > xite_profile
fi

if test $? -ne 0
then
  echo "ERROR:" 1>&2
  echo "Editing xite_profile failed." 1>&2
  echo "" 1>&2
  $paramMessage 1>&2

  exit 1
fi

exit 0
