From 7f7b77537cc4ce479b68fe510ffdd78bc7c45cad Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 23 Dec 2009 09:42:48 +0000 Subject: Support multiple bind addresses git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@435 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- bin/ldap2apache | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/bin/ldap2apache b/bin/ldap2apache index ef5a874..6085728 100755 --- a/bin/ldap2apache +++ b/bin/ldap2apache @@ -11,6 +11,7 @@ require "getoptlong" require "myldap" require "yaml" require "etc" +require 'ipaddr' @config = YAML::load( File.open( '/etc/noreply/config' ) ) ldap = MyLDAP.new(@config, "ldap2apache") @@ -48,6 +49,23 @@ def mkdir(dir, mode, uid, gid) end end +def make_vhostline(addresses, port) + line = [] + line << "" + return line.join(' ') +end + clients.each{ |c| c['vhosts'] = ldap.conn.search2(c['dn'][0], LDAP::LDAP_SCOPE_SUBTREE, '(&(objectclass=tnWebVHost)(tnHost='+@config['thishost']+'))') client_home = c['homeDirectory'][0] or throw "No home for #{d['dn'][0]}" @@ -59,7 +77,8 @@ clients.each{ |c| mkdir(client_home+"/logs-for-stat", 02750, 0, gid) mkdir(client_home+"/pg" , 02750, @postgres_uid, gid) c['vhosts'].each{ |vhost| - bind = vhost['tnWebVHostBind'] ? vhost['tnWebVHostBind'][0] : @defaultbind + bind = vhost['tnWebVHostBind'] ? vhost['tnWebVHostBind'] : @defaultbind + bind = [ bind ] unless bind.kind_of?(Array) bindhttpport = vhost['tnWebVHostBindHTTPPort'] ? vhost['tnWebVHostBindHTTPPort'][0] : @defaultbindhttpport bindhttpsport = vhost['tnWebVHostBindHTTPSPort'] ? vhost['tnWebVHostBindHTTPSPort'][0] : @defaultbindhttpsport server_name = vhost['tnWebVHostServerName'][0] @@ -167,7 +186,7 @@ clients.each{ |c| STDERR.puts "Warning: #{crtfile} does not exist" unless FileTest.exists?(crtfile) STDERR.puts "Warning: #{keyfile} does not exist" unless FileTest.exists?(keyfile) - config << "" + config << make_vhostline(bind, bindhttpsport) config << " SSLEngine on" config << " SSLCertificateFile #{crtfile}" config << " SSLCertificateKeyFile #{keyfile}" @@ -177,7 +196,7 @@ clients.each{ |c| config << ' SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown' config << '' else - config << "" + config << make_vhostline(bind, bindhttpport) end config << " ServerName #{server_name}" config << " ServerAlias #{server_aliases}" if server_aliases != "" @@ -328,7 +347,7 @@ clients.each{ |c| if ssl and http_ssl_upgrade config = [] - config << "" + config << make_vhostline(bind, bindhttpport) config << " ServerName #{server_name}" config << " ServerAlias #{server_aliases}" if server_aliases != "" config << " ServerAdmin #{server_admin}" -- cgit v1.2.3