HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2014-03-21 1ea0bc8966a632a11f89fe9a20a9b7f10c334cb4
erzeuge pac-addr-ipv4
1 files added
2 files modified
82 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java 58 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm 12 ●●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/InitDataTest.java 12 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -49,33 +49,6 @@
        }
    }
    private Processor createAccountingRulesProc() {
        return new ShellProcessor("mk-iptables-rules Accounting");
    }
    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 "
                                + " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) "));
        return domSetupProcessor;
    }
    @Override
    public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity)
            throws ProcessorException {
@@ -109,12 +82,41 @@
        }
    }
    private Processor createAccountingRulesProc() {
        return new ShellProcessor("mk-iptables-rules Accounting");
    }
    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 "
                                + " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) "));
        return domSetupProcessor;
    }
    private Processor createEtcHostsProc(Hive hive) throws ProcessorException {
        return new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", hive, "/etc/hosts", true);
    }
    private Processor createNetworkInterfacesProc(Hive hive) throws ProcessorException {
        return new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", hive, "/etc/network/interfaces", true);
        VelocityProcessor interfacesProc = new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", hive, "/etc/network/interfaces", true);
        VelocityProcessor pacIPv4Proc = new VelocityProcessor("/de/hsadmin/mods/pac/pac-addr-ipv4.vm", hive, "/etc/network/pac-addr-ipv4", true);
        return new CompoundProcessor(interfacesProc, pacIPv4Proc);
    }
    private Processor createIPTablesProc() {
hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm
New file
@@ -0,0 +1,12 @@
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
#foreach( $pac in ${hive.pacs} )
#if( !${pac.managedServer} )
eth0:${pac.name}:${pac.curINetAddr.inetAddr}/32
#end
#end
hsarback/test/de/hsadmin/remote/InitDataTest.java
@@ -36,8 +36,15 @@
        client = null;
        cas = null;
    }
    @Test
    public void initData() {
        testAdd1Member();
        testAdd2Pac();
        testAdd3User();
        testAdd4Domain();
    }
    public void testAdd1Member() {
        String user = "ad";
        int membersCount = -9999;
@@ -70,7 +77,6 @@
        }
    }
    @Test
    public void testAdd2Pac() {
        int count = getPacsCount();
        String user = "ad";
@@ -98,7 +104,6 @@
        assertEquals(count + 1, getPacsCount());
    }
    @Test
    public void testAdd3User() {
        int count = getUsersCount();
        try {
@@ -127,7 +132,6 @@
        assertEquals(count + 1, getUsersCount());
    }
    @Test
    public void testAdd4Domain() {
        int count = getUsersCount();
        try {