Commit 018c08fe authored by anarcat's avatar anarcat Committed by anarcat

factor out a common apache config file writing routine

parent b7c170b9
......@@ -83,24 +83,31 @@ function _provision_apache_create_vhost_config($url, $template = NULL) {
if (is_null($template)) {
$template = _provision_apache_default_template();
}
drush_log(dt("Generate virtual host configuration file."));
$writable = provision_path("writable", drush_get_option('vhost_path'), TRUE , NULL,
dt("Virtual host configuration path @path is not writable."),
'PROVISION_VHOST_PATH_NOT_WRITABLE');
$options['extra_config'] = "# Extra configuration from modules:\n";
foreach (drush_command_implements('provision_vhost_config') as $module) {
$options['extra_config'] .= "# -- $module settings --\n";
$options['extra_config'] .= module_invoke($module, 'provision_vhost_config', $url, $options) . "\n";
}
return _provision_apache_create_config($url, $options, $template);
}
/**
* Write an apache configuration file
*/
function _provision_apache_create_config($file, $data, $template) {
drush_log(dt("Generating apache host configuration file %file.", array('%file' => $file)));
$writable = provision_path("writable", drush_get_option('vhost_path'), TRUE , NULL,
dt("Virtual host configuration path @path is not writable."),
'PROVISION_VHOST_PATH_NOT_WRITABLE');
if ($writable) {
$file = fopen(drush_get_option('vhost_path') .'/'. $url, "w");
$text = provision_render_config($template, $options);
$file = fopen(drush_get_option('vhost_path') .'/'. $file, "w");
$text = provision_render_config($template, $data);
fwrite($file, $text);
fclose($file);
}
}
/**
* Restart Apache
*/
......
......@@ -4,17 +4,8 @@ function provision_apache_provision_verify($url) {
if (PROVISION_CONTEXT_PLATFORM) {
_provision_create_dir(drush_get_option('vhost_path'), dt("Virtual host configuration"), 0700);
$data = drush_get_merged_options();
drush_log(dt("Generating platform apache configuration file"));
$writable = provision_path("writable", drush_get_option('vhost_path'), TRUE , NULL,
dt("Virtual host configuration path @path is not writable."),
'PROVISION_VHOST_PATH_NOT_WRITABLE');
$options = drush_get_context('options');
if ($writable) {
$file = fopen(drush_get_option('vhost_path') .'/_platform_' . $options['platform'] . '.conf', "w");
$text = provision_render_config(_provision_apache_platform_template(), $data);
fwrite($file, $text);
fclose($file);
}
_provision_apache_create_config('_platform_' . $options['platform'] . '.conf', $data, _provision_apache_platform_template());
}
else {
_provision_apache_create_vhost_config($url);
......
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