echo
echo "Stopping asterisk...."
echo
if [ "A`ps -e | grep asterisk | grep -v grep`" = "A" ]; then
echo
echo "THE PROGRAM asterisk DOES NOT APPEAR TO BE RUNNING."
echo

else
echo -n "KILLING PROCESS: "
ps -e | grep asterisk | awk {'print $1'}
kill `ps -e | grep asterisk | awk {'print $1'}`

echo
echo "Checking to see if killed...please wait...."
echo
sleep 3

if [ "A`ps -e | grep asterisk | grep -v grep`" = "A" ]; then
echo
echo "KILL was successful - asterisk has been stopped."
echo
else
echo
echo "KILL WAS NOT SUCCESSFUL - PLEASE USE kill -9 <pid>"
echo "AND KILL IT MANUALLY, OR RESTART THE SYSTEM WITH init 6"
echo "IF ALL ELSE FAILS."
echo
fi

fi

