#!/bin/bash

# Signal is a parameter that determine the signal sent to kill command defaults to forced
if [ -z "$1" ]; then
    KILL_SIGNAL='-9'
else
    KILL_SIGNAL=$1
fi

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ABS_HOME=$SCRIPT_DIR/../..
ABS_HOME=$(builtin cd $ABS_HOME; pwd)

# Find the PID of the Java process containing ABS_HOME in the command line
PID=$(pgrep -f "$ABS_HOME/Reportserver/Lib")

if [ -n "$PID" ]; then
    echo "Killing Java process with PID $PID"
    kill $KILL_SIGNAL "$PID"
else
    echo "No Java process found with ABS_HOME in the command line"
fi


