Allow to use LAMP applications without configuration

parent b893666f
...@@ -85,28 +85,30 @@ class Recipe(GenericBaseRecipe): ...@@ -85,28 +85,30 @@ class Recipe(GenericBaseRecipe):
with open(secret_key_filename, 'r') as secret_key_file: with open(secret_key_filename, 'r') as secret_key_file:
secret_key = secret_key_file.read() secret_key = secret_key_file.read()
application_conf = dict(mysql_database=self.options['mysql-database'], # Generate application configuration file
mysql_user=self.options['mysql-username'], if self.options.get('template'):
mysql_password=self.options['mysql-password'], application_conf = dict(mysql_database=self.options['mysql-database'],
mysql_host='%s:%s' % (self.options['mysql-host'], mysql_user=self.options['mysql-username'],
self.options['mysql-port']), mysql_password=self.options['mysql-password'],
secret_key=secret_key, mysql_host='%s:%s' % (self.options['mysql-host'],
) self.options['mysql-port']),
secret_key=secret_key,
)
directory, file_ = os.path.split(self.options['configuration']) directory, file_ = os.path.split(self.options['configuration'])
path = self.options['htdocs'] path = self.options['htdocs']
if directory: if directory:
path = os.path.join(path, directory) path = os.path.join(path, directory)
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path) os.makedirs(path)
if not os.path.isdir(path): if not os.path.isdir(path):
raise OSError("Cannot create %r." % path) raise OSError("Cannot create %r." % path)
destination = os.path.join(path, file_) destination = os.path.join(path, file_)
config = self.createFile(destination, config = self.createFile(destination,
self.substituteTemplate(self.options['template'], application_conf)) self.substituteTemplate(self.options['template'], application_conf))
path_list.append(config) path_list.append(config)
if os.path.exists(self.options['pid-file']): if os.path.exists(self.options['pid-file']):
# Reload apache configuration # Reload apache configuration
......
...@@ -116,6 +116,14 @@ output = ${buildout:directory}/template-pull-backup.cfg ...@@ -116,6 +116,14 @@ output = ${buildout:directory}/template-pull-backup.cfg
md5sum = 9aab30ba5aa23a37d4b507e7c414be00 md5sum = 9aab30ba5aa23a37d4b507e7c414be00
mode = 0644 mode = 0644
# Dummy parts in case no application configuration file is needed
[application-template]
filename =
location =
[application-configuration]
location =
[eggs] [eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = eggs =
......
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