erzeuge pac-addr-ipv4

This commit is contained in:
Peter Hormanns 2014-03-21 15:48:46 +01:00
parent 12a1556b34
commit 1ea0bc8966
3 changed files with 50 additions and 32 deletions

View File

@ -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 <T extends AbstractEntity> 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() {

View 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

View File

@ -38,6 +38,13 @@ public class InitDataTest {
}
@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 {