#!/bin/bash
#

APP_NAME=$1

if [ "`pgrep $APP_NAME`" ]; then
        echo "$APP_NAME is currently running, shutting down..."
        for each in `seq 1 10`; do
		kill -9 `pgrep $APP_NAME`
                #asterisk -rx "core stop now" > /dev/null 2>&1
                echo -n "."
                sleep 1
                if [ ! "`pgrep $APP_NAME`" ]; then echo "$APP_NAME has been shut down"; break; fi
        done
fi
if [ "`pgrep $APP_NAME`" ]; then
        echo "Unable to shut down $APP_NAME"
fi
