#!/bin/sh
# Stop the broker, check for errors.
# 
export QPID_PORT=`cat qpidd.port`
rm -f qpidd.port

# Wait for daemon to quit
../qpidd --quit || ERROR=$?
while ../qpidd --check >/dev/null 2>&1; do true; done

# Check qpidd.log.
egrep 'warn|error|critical' qpidd.log && {
    echo "Suspicious broker log entries in qpidd.log."
    ERROR=1
}

# Check valgrind log.
if test -n "$VALGRIND"; then
    source `dirname $0`/vg_check
    vg_check qpidd.vglog
fi

exit $ERROR
