def apache_configuration(ssl_template, non_ssl_template, apache2_dir='/etc/apache2')
config_file = File.join(apache2_dir, "sites-available","#{self.name}.conf")
config = Symbiosis::ConfigFiles::Apache.new(config_file, "#")
config.domain = self
document_root = File.join(self.directory,"public","htdocs")
unless File.directory?(document_root)
verbose "\tThe document root #{document_root} does not exist."
return nil
end
if ( self.ssl_enabled? )
begin
self.ssl_verify
config.template = ssl_template
verbose "\tSSL is enabled -- using SSL template"
rescue OpenSSL::OpenSSLError => err
warn "SSL configuration for #{self.name} is broken -- #{err.to_s} (#{err.class.to_s})"
if self.ssl_mandatory?
verbose "\tSSL is enabled and mandatory, but mis-configured. Skipping."
return nil
end
verbose "\tSSL is enabled but mis-configured -- using non-SSL template."
config.template = non_ssl_template
end
else
config.template = non_ssl_template
verbose "\tSSL is not enabled -- using non-SSL template"
end
return config
end