#!/bin/sh

# Get configuration data
#
# usage: getconf [<name>, [<name>,...]]
#
# Runs configutil on the Messaging Server instance database
#

PATH=/bin:/usr/bin:/usr/sbin:/sbin:/usr/etc:${PATH}
SERVERROOT=<msg.RootPath>
MSGADMINBIN=${SERVERROOT}/sbin
INSTANCEDIR=${SERVERROOT}/config
CONFIGROOT=${SERVERROOT}/config
export SERVERROOT INSTANCEDIR CONFIGROOT PATH

names=""
ret=0

[ -z "${1}" ] || names=$*

# If no name is specified, list the entire config database
#
if [ -z "${names}" ] ; then
    cd ${MSGADMINBIN} && ./configutil
    exit $?
fi

# fetch and print each name's value
#
for name in ${names} ; do
    cd ${MSGADMINBIN} && ./configutil -o "${name}"
    if [ $? -ne 0 ] ; then
        ret=1
    fi
done

exit ${ret}
