From f1c8a05983a86defe3c236b1104917c15a7f31fa Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Tue, 13 May 2014 20:09:43 +0200
Subject: [PATCH] Remove Pac IP-Configuration from network-interfaces

---
 hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm         |    6 ++----
 hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java |   30 ++++++++++++++++++++----------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
index 4390646..bb3f50d 100644
--- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -41,7 +41,7 @@
 				createSudouersProc(hive),
 				createProftpdConfProc(hive),
 				createMakePacDirectoryStructure(unixUser),
-				createIfUp(pacName),
+				createIfUp(pac),
 				createHttpdVirtualProc(hive),
 				createAccountingRulesProc());
 		} else {
@@ -69,7 +69,7 @@
 			Hive hive = pac.getHive();
 			WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
 			waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(
-				createIfDown(pac.getName()),
+				createIfDown(pac),
 				createEtcHostsProc(hive),
 				createNetworkInterfacesProc(hive),
 				createSudouersProc(hive),
@@ -113,10 +113,11 @@
 		return new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", hive, "/etc/hosts", true);
 	}
 
-	private Processor createNetworkInterfacesProc(Hive hive) throws ProcessorException {
-		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 createNetworkInterfacesProc(final Hive hive) throws ProcessorException {
+//		VelocityProcessor interfacesProc = new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", hive, "/etc/network/interfaces", true);
+		final VelocityProcessor pacIPv4Proc = new VelocityProcessor("/de/hsadmin/mods/pac/pac-addr-ipv4.vm", hive, "/etc/network/pac-addr-ipv4", true);
+		return pacIPv4Proc;
+//		return new CompoundProcessor(interfacesProc, pacIPv4Proc);
 	}
 
 	private Processor createIPTablesProc() {
@@ -183,12 +184,21 @@
 				);
 	}
 
-	private Processor createIfUp(String pacName) {
-		return new ShellProcessor("ifup eth0:" + pacName);
+	private Processor createIfUp(final Pac pac) {
+//		return new ShellProcessor("ifup eth0:" + pacName);
+		return new ShellProcessor("ip addr add " 
+				+ pac.getCurINetAddr().getInetAddr()
+				+ "/32 dev eth0 label eth0:"
+				+ pac.getName()
+			);
 	}
 
-	private Processor createIfDown(String pacName) {
-		return new ShellProcessor("ifdown eth0:" + pacName);
+	private Processor createIfDown(final Pac pac) {
+//		return new ShellProcessor("ifdown eth0:" + pacName);
+		return new ShellProcessor("ip addr del " 
+				+ pac.getCurINetAddr().getInetAddr()
+				+ "/32 dev eth0"
+			);
 	}
 
 	private UnixUser getPacAdminUser(Pac pac) throws ProcessorException {
diff --git a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm
index a2fb8cf..ef28820 100644
--- a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm
+++ b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm
@@ -2,11 +2,9 @@
 # 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
-
-        
+#end
\ No newline at end of file

--
Gitblit v1.9.1