#! /bin/sh

name=`./samhain-install.sh --print-config name`
sbin=`./samhain-install.sh --print-config sbin_dir`

MONIT=""
test -f /usr/local/bin/monit && MONIT="/usr/local/bin/monit"
if test x"$MONIT" = x
then
    test -f /usr/bin/monit && MONIT="/usr/bin/monit"
    if test x"$MONIT" = x
    then
	:
    else
	zz=`/usr/bin/monit status | grep ${name}`
	if test x"$zz" = x
	then
	    :
	else
	    ${MONIT} stop "${name}"
	    exit 0
	fi
    fi
fi

if test -f /etc/init.d/${name}
then
	/etc/init.d/${name} stop
elif test -f /etc/rc.d/init.d/${name}
then
	/etc/rc.d/init.d/${name} stop
else
	if test -f $sbin/$name
	then
		$sbin/$name stop
	fi
fi

exit 0
