#!/bin/sh
# Copyright (c) 1992, 1993 Black Market Technologies, Inc.
# This is proprietary software.  You must purchase a license for each computer
# on which you want to use this software.  For complete licensing information, 
# check the license agreement that came with this software or contact
# Black Market Technologies at +1 718 522-5090.
# 
# Usage: $0
# $Id: get-mailhost,v 1.4 1993/08/01 06:14:34 treed Exp treed $
# $Author: treed $ $Date: 1993/08/01 06:14:34 $

# get name of mailhost 

CIN=4

PROMPT="Connect It: ${CIN}: "
APP_PATH=$1
shift
PATH="${APP_PATH}/Scripts:${APP_PATH}:/etc:/usr/etc:/usr/ucb:/bin:/usr/bin"
export PATH

YES=0
NO=1
PROBLEM=9

MAILHOST="`niutil -read . /locations/sendmail 2>/dev/null | grep mailhost: | awk '{print $2}' 2>/dev/null`"

if test "${MAILHOST}" != "" ; then
#  echo "${MAILHOST}"
  exit ${YES}
fi

SENDMAIL_FILENAME="`${APP_PATH}/Scripts/get-sendmail.cf-filename ${APP_PATH} 2>/dev/null`"

if test ! -f "${SENDMAIL_FILENAME}"  ; then
#  echo "${PROMPT} Could not locate sendmail filename ${SENDMAIL_FILENAME}">&2
  exit ${PROBLEM}
else
  MAILHOST="`egrep '^DR' ${SENDMAIL_FILENAME} | sed 's/^DR//'`"
  echo "${MAILHOST}"
  if test "${MAILHOST}" = "" ; then
#    echo "${PROMPT} Could not determine mailhost" >&2
    exit ${PROBLEM}
  fi
  exit ${YES}
fi
