#!/bin/sh
# From OS/eximon.conf-Default
X11R5LIB=${EXIMON_X11R5LIB-/opt/X11R5/lib}
EXIMON_BINARY=${EXIMON_BINARY-$0.bin}
WINDOW_TITLE=${EXIMON_WINDOW_TITLE-'${hostname} eximon'}
LOG_DEPTH=${EXIMON_LOG_DEPTH-300}
LOG_WIDTH=${EXIMON_LOG_WIDTH-${EXIMON_WIDTH-950}}
LOG_BUFFER=${EXIMON_LOG_BUFFER-20K}
LOG_FONT=${EXIMON_LOG_FONT--misc-fixed-medium-r-normal-*-14-140-*-*-*-*-iso8859-1}
MENU_EVENT=${EXIMON_MENU_EVENT-'Shift<Btn1Down>'}
QUEUE_DEPTH=${EXIMON_QUEUE_DEPTH-200}
QUEUE_WIDTH=${EXIMON_QUEUE_WIDTH-${EXIMON_WIDTH-950}}
QUEUE_FONT=${EXIMON_QUEUE_FONT-${LOG_FONT}}
QUEUE_MAX_ADDRESSES=${EXIMON_QUEUE_MAX_ADDRESSES-10}
QUEUE_INTERVAL=${EXIMON_QUEUE_INTERVAL-300}
STRIPCHART_INTERVAL=${EXIMON_STRIPCHART_INTERVAL-60}
LOG_STRIPCHARTS='/ <= /in/
                 / => /out/
                 / => .+ D=/local/
                 / => .+ T=smtp/smtp/'
BODY_MAX=${EXIMON_BODY_MAX-20000}
# End of OS/eximon.conf-Default

# From Local/eximon.conf
MIN_HEIGHT=162
MIN_WIDTH=103
WINDOW_TITLE='${hostname} eximon'
LOG_DEPTH=300
LOG_WIDTH=950
LOG_BUFFER=20K
LOG_FONT=-misc-fixed-medium-r-normal-*-14-140-*-*-*-*-iso8859-1
QUEUE_DEPTH=200
QUEUE_WIDTH=950
QUEUE_FONT=$LOG_FONT
QUEUE_MAX_ADDRESSES=10
QUEUE_INTERVAL=300
ACTION_OUTPUT=yes
ACTION_QUEUE_UPDATE=yes
STRIPCHART_INTERVAL=60
LOG_STRIPCHARTS='/ <= /in/
                  / => /out/
                  /D=/local/
                  /T=smtp/smtp/'
SIZE_STRIPCHART=/var
# End of Local/eximon.conf

# Base source of start-up shell script for the Exim Monitor. Used to set the
# required environment variables before running the program. Using script
# rather than a configuration file means that computation can be done.
# The build process concatenates on the front of this various settings from
# os-specific files and from the user's configuration file.

# Copyright (c) 1996 University of Cambridge.
# See the file NOTICE for conditions of use and distribution.

# Determine where the spool directory is and whether there is any setting of
# log_file_path.. The strings /etc/exim.conf and /usr/sbin below are
# replaced by their compile-time settings when this source is build into a
# script. Search for an exim_path setting in the configure file; otherwise use
# the bin directory. Call that version of Exim to find the spool directory and
# the setting of log_file_path.

config=/etc/exim.conf

# Add code here to redefine "config" if an alternative configuration file
# should be used in some circumstances.

EXIM_PATH=`grep '^[	 ]*exim_path' $config | sed 's/.*=[	  ]*//'`
if test "$EXIM_PATH" = ""; then EXIM_PATH=/usr/sbin/exim; fi
SPOOL_DIRECTORY=`$EXIM_PATH -C /etc/exim.conf -bP spool_directory | sed 's/.*=[  ]*//'`
LOG_FILE_PATH=`$EXIM_PATH -C /etc/exim.conf -bP log_file_path | sed 's/.*=[  ]*//'`

# If log_file_path is empty, then the log we are interested in is called
# "mainlog" in the directory called "log" in the spool directory. Otherwise set
# up the name of the log file from the given path.

if [ "$LOG_FILE_PATH" = "" ] ; then
  LOG_FILE_NAME=$SPOOL_DIRECTORY/log/mainlog
else
  LOG_FILE_NAME=`echo $LOG_FILE_PATH | sed 's/%s/main/'`
fi

# The basename and hostname commands vary from system to system

basename=/usr/bin/basename
hostname=/bin/hostname

# SunOS5 is a pain in that they may be in one of two places. Set up
# a general mechanism for searching for them.

if [ "${basename}" = "look_for_it" ] ; then
  if [ -f /usr/bin/basename ] ; then
    basename=/usr/bin/basename
  else
    basename=/usr/ucb/basename
  fi
fi

if [ "${hostname}" = "look_for_it" ] ; then
  if [ -f /usr/bin/hostname ] ; then
    hostname=/usr/bin/hostname
  else
    hostname=/usr/ucb/hostname
  fi
fi

# Set hostname to the full hostname with the specified domain
# stripped off its end.

fullhostname=`${hostname}`
hostname=`${basename} ${fullhostname} .${DOMAIN}`

# Arrange for the window title field to be substituted by the shell
# so that it can contain either the full or the short host name. This
# is a tedious little bit of magic, but I don't know how to do it
# in a less tortuous way.

WINDOW_TITLE=`fullhostname=${fullhostname} hostname=${hostname} /bin/sh <<xx
echo ${WINDOW_TITLE}
xx
`

# Add the X11R5 library to the library path, and then export the
# environment variables used by eximon.

if [ "${LD_LIBRARY_PATH}" = "" ] ; then
  LD_LIBRARY_PATH=${X11R5LIB}
else
  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${X11R5LIB}
fi

export EXIM_PATH LD_LIBRARY_PATH \
  LOG_BUFFER LOG_DEPTH LOG_FILE_NAME LOG_FONT LOG_WIDTH \
  ACTION_OUTPUT ACTION_QUEUE_UPDATE\
  MENU_EVENT MIN_HEIGHT MIN_WIDTH \
  QUALIFY_DOMAIN QUEUE_DEPTH QUEUE_FONT QUEUE_INTERVAL QUEUE_MAX_ADDRESSES \
  QUEUE_TOTAL QUEUE_WIDTH SPOOL_DIRECTORY \
  START_DEPTH LOG_STRIPCHARTS SIZE_STRIPCHART STRIPCHART_INTERVAL WINDOW_TITLE

# Exec to the program we really want to run, thereby continuing in
# just the one process, and let it run in parallel with whatever
# called this script.

exec ${EXIMON_BINARY} $* &

# End
