Commit 5035baae authored by Marco Mariani's avatar Marco Mariani

added recipe for site and db init

parent 4db10c16
...@@ -60,6 +60,7 @@ setup(name=name, ...@@ -60,6 +60,7 @@ setup(name=name,
'dropbear.add_authorized_key = slapos.recipe.dropbear:AddAuthorizedKey', 'dropbear.add_authorized_key = slapos.recipe.dropbear:AddAuthorizedKey',
'dropbear.client = slapos.recipe.dropbear:Client', 'dropbear.client = slapos.recipe.dropbear:Client',
'dropbear = slapos.recipe.dropbear:Recipe', 'dropbear = slapos.recipe.dropbear:Recipe',
'drupal_init = slapos.recipe.drupal:InitRecipe',
'dumpmdb = slapos.recipe.dumpmdb:Recipe', 'dumpmdb = slapos.recipe.dumpmdb:Recipe',
'duplicity = slapos.recipe.duplicity:Recipe', 'duplicity = slapos.recipe.duplicity:Recipe',
'egg_test = slapos.recipe.erp5_test:EggTestRecipe', 'egg_test = slapos.recipe.erp5_test:EggTestRecipe',
......
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os
import subprocess
from slapos.recipe.librecipe import GenericBaseRecipe
class InitRecipe(GenericBaseRecipe):
"""\
This recipe performs deployment steps for Drupal:
- Call the 'drush' command to install a Drupal site and initial database schema.
"""
def install(self):
drush_binary = self.options['drush-binary']
htdocs = self.options['htdocs']
os.chdir(htdocs)
output = subprocess.check_output([drush_binary,
'-y', 'site-install',
'--account-name=admin',
'--account-pass=admin'
])
# XXX return what?
return []
[buildout]
[drupal-init]
recipe = slapos.cookbook:drupal_init
drush-binary = ${apache-php:location}/bin/drush
htdocs = $${rootdirectory:srv}/www
dependency = $${apache-php:recipe}
...@@ -200,12 +200,23 @@ ...@@ -200,12 +200,23 @@
* ); * );
* @endcode * @endcode
*/ */
/*
* The apachephp recipe provided with both host+port in the same string.
* Split them again, php way.
* And it could be an ipv6 as well, so beware of colons.
*/
$mysql_host_port = '%(mysql_host)s';
$mysql_port = substr(strrchr($mysql_host_port, ":"), 1);
$mysql_host = substr($mysql_host_port, 0, strlen($mysql_host_port) - strlen($mysql_port) - 1);
$databases['default']['default'] = array( $databases['default']['default'] = array(
'driver' => 'mysql', 'driver' => 'mysql',
'database' => '%(mysql_database)s', 'database' => '%(mysql_database)s',
'username' => '%(mysql_user)s', 'username' => '%(mysql_user)s',
'password' => '%(mysql_password)s', 'password' => '%(mysql_password)s',
'host' => '%(mysql_host)s', 'host' => $mysql_host,
'port' => $mysql_port,
'prefix' => '', 'prefix' => '',
); );
......
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
extends = extends =
../../stack/lamp/buildout.cfg ../../stack/lamp/buildout.cfg
develop =
/opt/slapdev
parts +=
pear-modules
[application] [application]
recipe = slapos.recipe.build:download-unpacked recipe = slapos.recipe.build:download-unpacked
url = http://ftp.drupal.org/files/projects/drupal-7.16.tar.gz url = http://ftp.drupal.org/files/projects/drupal-7.16.tar.gz
...@@ -11,16 +18,33 @@ md5sum = 352497b2df94b5308e31cb8da020b631 ...@@ -11,16 +18,33 @@ md5sum = 352497b2df94b5308e31cb8da020b631
[application-template] [application-template]
recipe = slapos.recipe.download recipe = slapos.recipe.download
url = ${:_profile_base_location_}/settings.php.in url = ${:_profile_base_location_}/settings.php.in
md5sum = add9e4e96094a9d3fb7cf0f4d26ae544 md5sum = b4dfbdb950c25c93a8c3f9f78e9bff6e
download-only = True download-only = True
filename = template.in filename = template.in
mode = 0644 mode = 0644
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
[application-configuration] [application-configuration]
location = sites/default/default.settings.php location = sites/default/settings.php
[custom-application-deployment] [custom-application-deployment]
path = {:_profile_base_location_}/instance.cfg path = ${custom-application-deployment-template:output}
part-list = part-list = drupal-init
setup-database
[custom-application-deployment-template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg
md5sum = bd071532528120f5da1fb6050d4c80e8
mode = 0644
[pear-modules]
recipe = cp.recipe.cmd
pear = ${apache-php:location}/bin/pear
install_cmd =
${:pear} channel-info pear.drush.org >/dev/null || ${:pear} channel-discover pear.drush.org
${:pear} info drush/drush >/dev/null || ${:pear} install drush/drush
${:pear} info Console_Table >/dev/null || ${:pear} install Console_Table
[buildout] [buildout]
extends = ${custom-php-part:path} extends = ${custom-application-deployment:path}
parts = parts =
certificate-authority certificate-authority
...@@ -15,7 +15,7 @@ parts = ...@@ -15,7 +15,7 @@ parts =
frontend-promise frontend-promise
content-promise content-promise
publish-connection-informations publish-connection-informations
${custom-php-part:part-list} ${custom-application-deployment:part-list}
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
......
...@@ -84,7 +84,7 @@ mode = 0644 ...@@ -84,7 +84,7 @@ mode = 0644
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/apache/instance-apache-php.cfg url = ${:_profile_base_location_}/apache/instance-apache-php.cfg
output = ${buildout:directory}/template-apache-php.cfg output = ${buildout:directory}/template-apache-php.cfg
md5sum = a5dd222b3faa4e1ef2df9b3b9bb47966 md5sum = f789d2a84e0cd3ca28a6377c4f7b5ab2
mode = 0644 mode = 0644
[template-apache-backup] [template-apache-backup]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment