#!/bin/sh

export PYTHONPATH=%%PYTHON_LIBDIR%%:%%PYTHON_SITELIBDIR%%/exabgp

INTERPRETER=%%PYTHON_CMD%%

APPLICATIONS=`$INTERPRETER -c "import sys,os; print ' '.join(os.path.join(_,'exabgp','application','bgp.py') for _ in sys.path if os.path.isfile('/'.join((_,'exabgp','application','bgp.py'))))"`
APPLICATION=`echo $APPLICATIONS | awk '{ print $1; }'`

if [ $# -eq 0 ]; then
	$INTERPRETER -m exabgp $APPLICATION --folder %%PREFIX%%/etc/exabgp --help
	echo "===> To start exabgp, you should use:"
	echo "===>   service exabgp start"
else
	exec $INTERPRETER -m exabgp $APPLICATION --folder %%PREFIX%%/etc/exabgp $*
fi
