#!/bin/bash
#
# This file is released under the terms of the Artistic License.
# Please see the file LICENSE, included in this package, for details.
#
# Copyright The DBT-2 Authors
#

if [ "x" = "x${DBT2DATADIR}" ]; then
	echo "ERROR: DBT2DATADIR must be set"
	exit 1
fi

HOSTNAME=`hostname`

if [ ! -f "${DBT2DATADIR}/${HOSTNAME}.pid" ]; then
	echo "MySQL pid file '${DBT2DATADIR}/${HOSTNAME}.pid' does not exist."
	echo "MySQL was not stopped, if it was running."
	exit 0
fi
MYSQL_PID=`cat ${DBT2DATADIR}/${HOSTNAME}.pid`
kill ${MYSQL_PID} || exit 1
sleep 10
echo "MySQL stopped successfully (by kill)."

exit 0
