HSAdmin Backend Domains, E-Mail, Datenbanken
Michael Hierweck
2017-06-29 0cee4abcfe1ccb85dfe966bfc6ef9c05d56ee06c
New virtual host configuration for pacs. Fallback/Default should be HTTP
404.
2 files modified
49 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java 20 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm 29 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -90,22 +90,10 @@
    private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException {
        Processor domSetupProcessor = new CompoundProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive,
                        "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true),
                new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " +
                        "ls $PEM >/dev/null 2>&1 || ( " +
                        " sed -i \"/SSLCertificateFile.*${PEM:18}/c \\\n" +
                        "\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" /etc/apache2/virtual.conf.tmp && " +
                        " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" +
                        "\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " +
                        "); " +
                        "done"),
                new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c29- ); do " +
                        "ls $PEM >/dev/null 2>&1 || " +
                        " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " +
                        "done"),
                new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf"
                                + " && rm /etc/apache2/virtual.conf.tmp )"
                                + " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf "
                        "/etc/apache2/conf.d/virtual.conf.tmp", "root", "root", "644", true),
                new ShellProcessor("(diff -q /etc/apache2/conf.d/virtual.conf.tmp /etc/apache2/conf.d/virtual.conf"
                                + " && rm /etc/apache2/conf.d/virtual.conf.tmp )"
                                + " || ( mv /etc/apache2/conf.d/virtual.conf.tmp /etc/apache2/conf.d/virtual.conf "
                                + " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) "));
        return domSetupProcessor;
    }
hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm
@@ -4,8 +4,29 @@
#
#foreach( $pac in ${hive.pacs} )
<VirtualHost ${pac.curINetAddr.inetAddr}:80>
    ServerName _
    ServerAdmin webmaster@${pac.getName}
# ${pac.name}
NameVirtualHost ${pac.curINetAddr.inetAddr}:80
NameVirtualHost ${pac.curINetAddr.inetAddr}:443
#end
    <Directory />
        Redirect 404 /
    </Directory>
</VirtualHost>
<VirtualHost ${pac.curINetAddr.inetAddr}:443>
    ServerName _
    ServerAdmin webmaster@${pac.getName}
    SSLEngine On
    SSLCertificateFile /etc/apache2/pems/default.pem
    SSLCertificateChainFile /etc/apache2/pems/default.chain.pem
    <Directory />
        SSLRequireSSL On
        Redirect 404 /
    </Directory>
</VirtualHost>
#end