diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index 12a837a..7d65a2e 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -33,12 +33,16 @@ public class DomainProcessorFactory implements EntityProcessorFactory { Domain dom = (Domain) entity; UnixUser domUser = dom.getUser(); Pac pac = domUser.getPac(); + String pacName = pac.getName(); String domName = dom.getName(); String zonefileTargetPath = "/etc/bind/pri." + domName; Map templateVars = new HashMap(); templateVars.put("SIO", Long.toString(System.currentTimeMillis()/1000L)); + templateVars.put("PAC", pacName); + templateVars.put("HIVE", pac.getHiveName()); templateVars.put("DOM_HOSTNAME", domName); - templateVars.put("PAC_HOSTNAME", pac.getName() + ".hostsharing.net"); + templateVars.put("DOM_USERNAME", domUser.getName()); + templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net"); templateVars.put("DOM_IPNUMBER", pac.getCurINetAddr().getInetAddr()); Processor zonefileTemplateProcessor = new TemplateProcessor("/de/hsadmin/mods/dom/zonefile.jtpl", templateVars, zonefileTargetPath, false); @@ -95,7 +99,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory { String domsDir = domUser.getHomedir() + "/doms"; String domainDir = domsDir + "/" + dom.getName(); String[] subDirs = new String[] { "htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "cgi", "fastcgi", "cgi-ssl", "fastcgi-ssl", "etc", "var" }; - String pacName = pac.getName(); String userName = domUser.getName(); Processor mkDomainDirProzessor = new ShellProcessor( @@ -112,8 +115,17 @@ public class DomainProcessorFactory implements EntityProcessorFactory { )); } templateVars = new HashMap(); + templateVars.put("PAC", pacName); + templateVars.put("HIVE", pac.getHiveName()); + templateVars.put("DOM_HOSTNAME", domName); + templateVars.put("DOM_USERNAME", domUser.getName()); + templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net"); + templateVars.put("DOM_IPNUMBER", pac.getCurINetAddr().getInetAddr()); templateVars.put("DOMAIN", domName); templateVars.put("USER_NAME", domUser.getComment()); + domDirsProcessor.appendProcessor( + new CreateFileProcessor("/de/hsadmin/mods/dom/httpd.conf.jtpl", templateVars, "/etc/apache2/sites-generated/" + domName, "root", "root", "644") + ); templateVars.put("PROTOCOL", "http"); domDirsProcessor.appendProcessor( new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.jtpl", templateVars, domainDir + "/htdocs/.htaccess", userName, pacName, "644") @@ -148,7 +160,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { mainProcessor.appendProcessor(hiveName, domDirsProcessor, "Setup doms/" + domName + "-Directory"); Processor domSetupProcessor = - new ShellProcessor("mk-httpd-conf " + pacName + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + new ShellProcessor("ln -s /etc/apache2/sites-generated/" + domName + " /etc/apache2/sites-enabled/010" + domName + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); mainProcessor.appendProcessor(hiveName, domSetupProcessor, "Setup Apache VHost"); return mainProcessor; } diff --git a/hsarback/src/de/hsadmin/mods/dom/httpd.conf.jtpl b/hsarback/src/de/hsadmin/mods/dom/httpd.conf.jtpl new file mode 100644 index 0000000..f100b2b --- /dev/null +++ b/hsarback/src/de/hsadmin/mods/dom/httpd.conf.jtpl @@ -0,0 +1,105 @@ +NameVirtualHost {DOM_IPNUMBER}:80 +NameVirtualHost {DOM_IPNUMBER}:80 + + + + ServerName {DOM_HOSTNAME} + ServerAlias *.{DOM_HOSTNAME} + ServerAdmin {DOM_USERNAME}@{HIVE}.hostsharing.net + + SuexecUserGroup {DOM_USERNAME} {PAC} + + DocumentRoot /home/doms/{DOM_HOSTNAME}/htdocs + + Alias /cgi-bin/ /home/doms/{DOM_HOSTNAME}/cgi/ + Alias /fastcgi-bin/ /home/doms/{DOM_HOSTNAME}/fastcgi/ + + + Options -ExecCGI +IncludesNOEXEC +Indexes +MultiViews +SymLinksIfOwnerMatch + + + + AllowOverride AuthConfig FileInfo Indexes Limit + + + + SetHandler cgi-script + Options +ExecCGI -Indexes -MultiViews + + + + SetHandler fcgid-script + Options +ExecCGI -Indexes -MultiViews + + + RewriteEngine On + RewriteOptions Inherit + #RewriteLog /home/doms/{DOM_HOSTNAME}/var/rewrite.log + #RewriteLogLevel 9 + + RewriteCond %{REQUEST_URI} !^/cgi-bin/ + RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ + RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary] + RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d + RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last] + + AddType application/x-httpd-php .php .php5 .php4 .php3 + Action application/x-httpd-php /fastcgi-bin/phpstub + + + +NameVirtualHost {DOM_IPNUMBER}:443 +NameVirtualHost {DOM_IPNUMBER}:443 + + + + ServerName {DOM_HOSTNAME} + ServerAlias *.{DOM_HOSTNAME} + ServerAdmin {DOM_USERNAME}@{HIVE}.hostsharing.net + + SuexecUserGroup {DOM_USERNAME} {PAC} + + SSLEngine On + SSLCertificateFile /etc/apache2/pems/default.pem + SSLCertificateChainFile /etc/apache2/pems/default.chain.pem + + DocumentRoot /home/doms/{DOM_HOSTNAME}/htdocs-ssl + + Alias /cgi-bin/ /home/doms/{DOM_HOSTNAME}/cgi-ssl/ + Alias /fastcgi-bin/ /home/doms/{DOM_HOSTNAME}/fastcgi-ssl/ + + + SSLRequireSSL On + Options -ExecCGI +IncludesNOEXEC +Indexes +MultiViews +SymLinksIfOwnerMatch + + + + AllowOverride AuthConfig FileInfo Indexes Limit + + + + SetHandler cgi-script + Options +ExecCGI -Indexes -MultiViews + + + + SetHandler fcgid-script + Options +ExecCGI -Indexes -MultiViews + + + RewriteEngine On + RewriteOptions Inherit + #RewriteLog /home/doms/{DOM_HOSTNAME}/var/rewrite.log + #RewriteLogLevel 9 + + RewriteCond %{REQUEST_URI} !^/cgi-bin/ + RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ + RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:443)?$ [novary] + RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} -d + RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1}$1 [last] + + AddType application/x-httpd-php .php .php5 .php4 .php3 + Action application/x-httpd-php /fastcgi-bin/phpstub + + + \ No newline at end of file