#!/bin/sh
# $OpenBSD: INSTALL-server,v 1.10 2004/10/12 21:14:42 espie Exp $
#
# Pre/post-installation setup of MySQL

PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
DB_DIR=${DB_DIR}

do_notice_existingdir()
{
  echo
  echo "+---------------"
  echo "| You appear to already have a MySQL database directory in $DB_DIR"
  echo "|"
  echo "| The database directory has been preserved. If you want to start"
  echo "| from the default database setup, you should perform these steps"
  echo "| as root:"
  echo "|"
  echo "|           rm -rf $DB_DIR"
  echo "|           $PREFIX/bin/mysql_install_db"
  echo "|"
  echo "+---------------"
  echo
}

do_database_install()
{
  $PREFIX/bin/mysql_install_db
}

case $2 in 
    POST-INSTALL)
	if [ -d $DB_DIR ]; then
	  do_notice_existingdir
	else
	  do_database_install
	fi
	;;
esac

exit 0
