Commit 4e5a356d authored by Marco Mariani's avatar Marco Mariani

use slapos.cookbook:generate.password

parent c419daae
......@@ -39,7 +39,6 @@ from slapos.recipe.librecipe import GenericBaseRecipe
# - drush connects to mysql with the password on command line
# see http://stackoverflow.com/questions/6607675/shell-script-password-security-of-command-line-parameters
# it could use a socket, but we are on a different instance than mysql
# - the admin_password is not published yet.
# - using slapproxy, sometimes this recipe is not able to connect to mysql (tunnel down).
# restarting from supervisor usually solves it.
#
......@@ -77,12 +76,11 @@ class InitRecipe(GenericBaseRecipe):
drush_output = subprocess.check_output([drush_binary,
'-y', 'site-install',
'--account-name=admin'
'--account-name=admin',
'--account-pass=%s' % self.options['admin-password'],
],
stderr=subprocess.STDOUT)
self.options['admin-password'] = self.extract_password(drush_output)
# drush removes the 'w' bit from both the settings file and its
# directory.
# we restore them, otherwise buildout will see the file as changed
......@@ -95,10 +93,6 @@ class InitRecipe(GenericBaseRecipe):
return []
def extract_password(self, drush_output):
return re.search('User password: (\S+)', drush_output).groups()[0]
def is_db_empty(self, php_binary, settings_php):
with tempfile.NamedTemporaryFile() as fout:
settings_dirname, settings_filename = os.path.split(settings_php)
......
......@@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush
php-binary = ${apache-php:location}/bin/php
settings-php = ${application-configuration:location}
htdocs = $${rootdirectory:srv}/www
#admin-password =
admin-password = $${gen-passwd:passwd}
dependency = $${apache-php:recipe}
#----------------
#--
#-- Generates a random password and stores it in the filesystem
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${directories:srv}/drupal_passwd
bytes = 16
[drupal-init]
recipe = iw.recipe.cmd
cmds =
$${drupal-init-base:drush-binary} install drush make build-datapublic.make DrupalDataPublic
......@@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg
md5sum = cde648fb7477fd5927062d6df575e895
md5sum = 4d07c8018c3e78e46a5f6cb1958434d4
mode = 0644
......
......@@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush
php-binary = ${apache-php:location}/bin/php
settings-php = ${application-configuration:location}
htdocs = $${rootdirectory:srv}/www
#admin-password =
admin-password = $${gen-passwd:passwd}
dependency = $${apache-php:recipe}
#----------------
#--
#-- Generates a random password and stores it in the filesystem
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${directories:srv}/drupal_passwd
bytes = 16
[drupal-init]
recipe = iw.recipe.cmd
cmds =
$${drupal-init-base:drush-binary} install drush make --prepare-install build-openpublic.make DrupalOpenPublic
......@@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg
md5sum = d318cbc4d417616b9d7afa4a398f3569
md5sum = 5a787592514eb5baa24edcda9a44f6b7
mode = 0644
......
......@@ -11,6 +11,16 @@ drush-binary = ${apache-php:location}/bin/drush
php-binary = ${apache-php:location}/bin/php
settings-php = ${application-configuration:location}
htdocs = $${rootdirectory:srv}/www
#admin-password =
admin-password = $${gen-passwd:passwd}
dependency = $${apache-php:recipe}
#----------------
#--
#-- Generates a random password and stores it in the filesystem
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${directories:srv}/drupal_passwd
bytes = 16
......@@ -34,7 +34,7 @@ part-list = drupal-init publish-drupal-admin-password
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg
md5sum = 283cb53ff8cd34635703e771062db919
md5sum = 30b3d75d79916ae25ef19969499a3aa2
mode = 0644
......
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