From 1bf4621235fbd761c4a0642c866eaaa7dc6007ae Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 7 Jun 2012 12:58:21 +0000
Subject: [PATCH] Implemented: FS#2131 - skip network reconfigure requests on
 mirror servers that are for a different server_id

---
 server/lib/classes/modules.inc.php                | 15 +++++++++++++--
 .../network_settings_plugin.inc.php               |  7 ++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/server/lib/classes/modules.inc.php b/server/lib/classes/modules.inc.php
index 143683d051..419bb91cf4 100644
--- a/server/lib/classes/modules.inc.php
+++ b/server/lib/classes/modules.inc.php
@@ -108,6 +108,7 @@ class modules {
 				*/
 				
 				$replication_error = false;
+				$data['mirrored'] = false;
 				
 				$this->current_datalog_id = $d['datalog_id'];
 				
@@ -115,9 +116,16 @@ class modules {
 				* If we are in a mirror setup, rewrite the server_id of records that originally 
 				* belonged to the mirrored server to the local server_id
 				*/
+				
 				if($conf['mirror_server_id'] > 0 && $d['dbtable'] != 'server') {
-					if(isset($data['new']['server_id']) && $data['new']['server_id'] == $conf['mirror_server_id']) $data['new']['server_id'] = $conf['server_id'];
-					if(isset($data['old']['server_id']) && $data['old']['server_id'] == $conf['mirror_server_id']) $data['old']['server_id'] = $conf['server_id'];
+					if(isset($data['new']['server_id']) && $data['new']['server_id'] == $conf['mirror_server_id']) {
+						$data['new']['server_id'] = $conf['server_id'];
+						$data['mirrored'] = true;
+					}
+					if(isset($data['old']['server_id']) && $data['old']['server_id'] == $conf['mirror_server_id']) {
+						$data['old']['server_id'] = $conf['server_id'];
+						$data['mirrored'] = true;
+					}
 				}
 				
 				if(count($data['new']) > 0) {
@@ -217,6 +225,9 @@ class modules {
 				}
 				*/
 				
+				//* Data on a single server is never mirrored
+				$data['mirrored'] = false;
+				
 				$this->current_datalog_id = $d['datalog_id'];
 				if(is_array($data['old']) || is_array($data['new'])) {
 					$this->raiseTableHook($d['dbtable'],$d['action'],$data);
diff --git a/server/plugins-available/network_settings_plugin.inc.php b/server/plugins-available/network_settings_plugin.inc.php
index 16b553b561..2bea30097e 100644
--- a/server/plugins-available/network_settings_plugin.inc.php
+++ b/server/plugins-available/network_settings_plugin.inc.php
@@ -79,8 +79,9 @@ class network_settings_plugin {
 		$app->uses('getconf');
 		$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
 		
-		// Configure the debian network card settings
-		if($server_config['auto_network_configuration'] == 'y') {
+		//* Configure the debian network card settings.
+		//* Dont configure
+		if($server_config['auto_network_configuration'] == 'y' && $data['mirrored'] == false) {
 			
 			if (is_file('/etc/debian_version')) 
 			{
@@ -238,7 +239,7 @@ class network_settings_plugin {
 			}
 			
 		} else {
-			$app->log('Network configuration disabled in server settings.',LOGLEVEL_DEBUG);
+			$app->log('Network configuration disabled in server settings or server is a mirror server.',LOGLEVEL_DEBUG);
 		}
 		
 	}
-- 
GitLab