diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index a517e2c..9bc0f60 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -49,33 +49,6 @@ public class PacProcessorFactory implements EntityProcessorFactory { } } - 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 Processor createUpdateProcessor(EntityManager em, T entity) throws ProcessorException { @@ -109,12 +82,41 @@ public class PacProcessorFactory implements EntityProcessorFactory { } } + 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() { diff --git a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm new file mode 100644 index 0000000..a2fb8cf --- /dev/null +++ b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm @@ -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 + + diff --git a/hsarback/test/de/hsadmin/remote/InitDataTest.java b/hsarback/test/de/hsadmin/remote/InitDataTest.java index a03e1fd..05571f6 100644 --- a/hsarback/test/de/hsadmin/remote/InitDataTest.java +++ b/hsarback/test/de/hsadmin/remote/InitDataTest.java @@ -36,8 +36,15 @@ public class InitDataTest { 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 @@ public class InitDataTest { } } - @Test public void testAdd2Pac() { int count = getPacsCount(); String user = "ad"; @@ -98,7 +104,6 @@ public class InitDataTest { assertEquals(count + 1, getPacsCount()); } - @Test public void testAdd3User() { int count = getUsersCount(); try { @@ -127,7 +132,6 @@ public class InitDataTest { assertEquals(count + 1, getUsersCount()); } - @Test public void testAdd4Domain() { int count = getUsersCount(); try {