#!/usr/bin/env bash

ROOT_UID=0	 # root uid is 0
E_NOTROOT=67	 # Non-root exit error


echo
# check to see if we are root
if [ "$UID" -ne "$ROOT_UID" ]
then
	echo "Sorry, you must be root to run this script."
	echo
	exit $E_NOTROOT
fi

# make sure config file exists
if [ ! -e "/etc/amportal.conf" ]       # Check if file exists.
  then
    echo;
    echo "/etc/amportal.conf does not exist!";
	echo "Have you installed the AMP configuration?";
	exit;
fi
. /etc/amportal.conf

if [ -x ${AMPBIN}/freepbx_engine ]
then
	${AMPBIN}/freepbx_engine $@
elif [ -x ${ASTVARLIBDIR}/bin/freepbx_engine ]
then
	${ASTVARLIBDIR}/bin/freepbx_engine $@
elif [ -x /var/lib/asterisk/bin/freepbx_engine ]
then
	/var/lib/asterisk/bin/freepbx_engine $@
else
	echo "FATAL: can not find freepbx_engine to start Asterisk"
fi

