#!/bin/sh

HOME=/usr/local/megha

printf "This will remove all data collected by Megha. Do you wish to continue? [yes/no]"
read ANSWER

if [ "$ANSWER" != "yes"  ]; then
    echo "Ok. Will exit now."
    exit
fi

printf "Megha services need to be stopped before removing data. Do you wish to stop Megha services? [yes/no]"
read ANSWER

if [ "$ANSWER" != "yes"  ]; then
    echo "Ok. Will exit now."
    exit
fi

echo "Stopping Megha services ..."
/usr/local/megha/bin/megha-probe.sh stop
/usr/local/megha/bin/megha-tomcat.sh stop
echo "Done ..."

echo "Removing data ..."
if test "$HOME" == ""
then
    echo "Megha home directory not defined!!!"
else
    \rm -rf /usr/local/megha/db/*
    \rm -rf /usr/local/megha/logs/*
    \rm -rf /usr/local/megha/template/*
fi
echo "Done"

