Commit b9fca014 authored by Alain Takoudjou's avatar Alain Takoudjou

Allow to send env variable and custom config to apache recipe

parent 25c5fba2
...@@ -33,6 +33,27 @@ from slapos.recipe.librecipe import GenericBaseRecipe ...@@ -33,6 +33,27 @@ from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
def __init__(self, buildout, name, options):
self.environ = {}
environment_section = options.get('environment-section', '').strip()
if environment_section and environment_section in buildout:
# Use environment variables from the designated config section.
self.environ.update(buildout[environment_section])
for variable in options.get('environment', '').splitlines():
if variable.strip():
try:
key, value = variable.split('=', 1)
self.environ[key.strip()] = value
except ValueError:
raise zc.buildout.UserError('Invalid environment variable definition: %s', variable)
# Extrapolate the environment variables using values from the current
# environment.
for key in self.environ:
self.environ[key] = self.environ[key] % os.environ
return GenericBaseRecipe.__init__(self, buildout, name, options)
def install(self): def install(self):
path_list = [] path_list = []
...@@ -50,6 +71,7 @@ class Recipe(GenericBaseRecipe): ...@@ -50,6 +71,7 @@ class Recipe(GenericBaseRecipe):
path_list.append(php_ini) path_list.append(php_ini)
# Install apache # Install apache
if self.optionIsTrue('default-conf', True):
apache_config = dict( apache_config = dict(
pid_file=self.options['pid-file'], pid_file=self.options['pid-file'],
lock_file=self.options['lock-file'], lock_file=self.options['lock-file'],
...@@ -66,10 +88,11 @@ class Recipe(GenericBaseRecipe): ...@@ -66,10 +88,11 @@ class Recipe(GenericBaseRecipe):
) )
path_list.append(httpd_conf) path_list.append(httpd_conf)
wrapper = self.createPythonScript(self.options['wrapper'], apache_args = [self.options['httpd-binary'], '-f', self.options['httpd-conf'],
'slapos.recipe.librecipe.execute.execute',
[self.options['httpd-binary'], '-f', self.options['httpd-conf'],
'-DFOREGROUND'] '-DFOREGROUND']
wrapper = self.createPythonScript(self.options['wrapper'],
'slapos.recipe.librecipe.execute.executee',
(apache_args, self.environ)
) )
path_list.append(wrapper) path_list.append(wrapper)
......
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