diff --git a/web_server/provision_apache.drush.inc b/web_server/provision_apache.drush.inc index 1c2e14d2332360a1206932d9384465ab5e3bd5f8..93b044e1c54f105bf24bb1d5de8caeccce1c4743 100644 --- a/web_server/provision_apache.drush.inc +++ b/web_server/provision_apache.drush.inc @@ -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 */ diff --git a/web_server/verify.provision.inc b/web_server/verify.provision.inc index 9c1345ffc7b17dec86a7570f198cf3781759c4ec..be4723893c2132b965d7a63ba50dd54a1c12e33d 100644 --- a/web_server/verify.provision.inc +++ b/web_server/verify.provision.inc @@ -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);