HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2011-07-15 c16d9213d0433204e79f6d8229cba2d9c0090a8b
mk-httpd-conf entfaellt
1 files modified
1 files added
123 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 18 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/httpd.conf.jtpl 105 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -33,12 +33,16 @@
        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<String, String> templateVars = new HashMap<String, String>();
        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 @@
        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 @@
                ));
        }
        templateVars = new HashMap<String, String>();
        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 @@
        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;
    }
hsarback/src/de/hsadmin/mods/dom/httpd.conf.jtpl
New file
@@ -0,0 +1,105 @@
NameVirtualHost {DOM_IPNUMBER}:80
NameVirtualHost {DOM_IPNUMBER}:80
<VirtualHost {DOM_IPNUMBER}:80 {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/
    <Directory />
        Options -ExecCGI +IncludesNOEXEC +Indexes +MultiViews +SymLinksIfOwnerMatch
    </Directory>
    <Directory /home/doms/{DOM_HOSTNAME}/>
       AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI -Indexes -MultiViews
    </Location>
    <Location /fastcgi-bin/>
        SetHandler fcgid-script
        Options +ExecCGI -Indexes -MultiViews
    </Location>
    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
</VirtualHost>
NameVirtualHost {DOM_IPNUMBER}:443
NameVirtualHost {DOM_IPNUMBER}:443
<VirtualHost {DOM_IPNUMBER}:443 {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/
    <Directory />
        SSLRequireSSL On
        Options -ExecCGI +IncludesNOEXEC +Indexes +MultiViews +SymLinksIfOwnerMatch
    </Directory>
    <Directory /home/doms/{DOM_HOSTNAME}/>
        AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI -Indexes -MultiViews
    </Location>
    <Location /fastcgi-bin/>
        SetHandler fcgid-script
        Options +ExecCGI -Indexes -MultiViews
    </Location>
    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
</VirtualHost>