# This is data only part of buildout for mysql with senna
# made by Leonardo Rochael Almeida <leorochael@gmail.com> (thanks!)
# Original place: https://svn.erp5.org/repos/public/experimental/mysqlsenna.buildout/

[buildout]
parts =
    mysql-instance

[configuration]
mysql_port = 10002
mysql_host = 127.0.0.1
mysql_datadir = ${buildout:var-directory}/mysql
mysql_pid = ${:mysql_datadir}/mysql.pid
mysql_sock = ${:mysql_datadir}/mysql.sock
mysql_error_log = ${buildout:log-directory}/mysql.err.log
mysql_cnf_file = ${buildout:etc-directory}/my.cnf

[mysql-bin]
recipe = collective.recipe.template
input = ${buildout:directory}/mysql-instance/templates/mysql.in
output = ${buildout:data-bin-directory}/mysql

[mysql-admin]
recipe = collective.recipe.template
input = ${buildout:directory}/mysql-instance/templates/mysqladmin.in
output = ${buildout:data-bin-directory}/mysqladmin

[mysqld_safe-bin]
recipe = collective.recipe.template
input = ${buildout:directory}/mysql-instance/templates/mysqld_safe.in
output = ${buildout:data-bin-directory}/mysqld_safe

[mysql-cnf]
recipe = collective.recipe.template
input = ${buildout:directory}/mysql-instance/templates/my.cnf.in
output = ${configuration:mysql_cnf_file}

[mysql-instance]
depends =
  ${create-directories:command}
  ${mysql-cnf:output}
  ${mysql-bin:output}
  ${mysql-admin:output}
  ${mysqld_safe-bin:output}

recipe = plone.recipe.command
command =
    mkdir -p ${configuration:mysql_datadir}
    ${software_definition:software_home}/bin/mysql_install_db --datadir=${configuration:mysql_datadir}

[start-mysql-instance]
recipe = plone.recipe.command
command = ${buildout:data-bin-directory}/bin/mysqld_safe &
update-command = ${:command}

[stop-mysql-instance]
recipe = plone.recipe.command
command = kill `cat ${configuration:mysql_pid}`
update-command = ${:command}