#!/bin/sh
# start this instance of the Netscape Messaging Server
#
# usage: ./start-msg [components]
#
# where components is one of smtp, imap, pop, store, or http
#

SERVERROOT=<msg.RootPath>
CONFIGROOT=${SERVERROOT}/config
export CONFIGROOT SERVERROOT

# LIBPATH is set for AIX 4+
# SHLIB_PATH is set for HPUX 11+
# LD_LIBRARY_PATH used for Solaris 2.5+, SCO Unix, IRIX, Linux
ADDPATH=${SERVERROOT}/lib
LD_LIBRARY_PATH=${ADDPATH}:${LD_LIBRARY_PATH}
LIBPATH=${ADDPATH}:${LIBPATH}
SHLIB_PATH=${ADDPATH}:${SHLIB_PATH}
SUID_OK_LIBPATH=${LIBPATH}
export LD_LIBRARY_PATH LIBPATH SHLIB_PATH SUID_OK_LIBPATH

# SMS and SNMP variables
IMTA_TAILOR="`${SERVERROOT}/lib/configutil -o local.imta.imta_tailor`"
export IMTA_TAILOR

VCSCMD=/opt/VRTSvcs/bin/hares 
SC2CMD=/opt/SUNWcluster/bin/hareg
SC3CMD=/usr/cluster/lib/rgm/rtreg/SUNW.ims

HA_usage()
{
	echo "Warning: a HA configuration is detected on your system,"
	echo "use the HA start command to properly start the messaging server."  		 
	exit 2
}

IP_INTERFACE=`${SERVERROOT}/lib/configutil -o service.listenaddr`
if [ $# -eq 0 -a \
     ! \( -z "$IP_INTERFACE" -o "$IP_INTERFACE" = "INADDR_ANY" \) -a \
     \( -f "$VCSCMD" -o -f "$SC2CMD" -o -f "$SC3CMD" \) ]; then
	HA_usage;
fi

OSNAME=`uname`
if [ $OSNAME = Linux ]; then
  /sbin/ldconfig $SERVERROOT/lib
fi

components="$*"

if [ -z "${components}" ]
then
    ${SERVERROOT}/lib/msstart
elif [ "${components}" = ha ]
then
    ${SERVERROOT}/lib/msstart -a
else
    ${SERVERROOT}/lib/msstart ${components}
fi

