From 3da03977f5beba6940403f4308d9b72a16b5c0fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?A=2E=20T=C3=A4ffner?= <darkalex@firesplash.de>
Date: Thu, 8 Sep 2016 10:19:34 +0200
Subject: [PATCH] Implementation of detection override to configure webserver
 wheenver the panel is installed on the host regardless of user's preference

---
 install/lib/update.lib.php |  8 ++++++--
 install/update.php         | 17 +++++++++--------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php
index a4df4d8328..c1ed313355 100644
--- a/install/lib/update.lib.php
+++ b/install/lib/update.lib.php
@@ -431,8 +431,12 @@ function check_service_config_state($servicename, $detected_value) {
 	else $current_state = 0;
 	
 	if ($detected_value != $current_state) {
-		if ($inst->simple_query('Service \''.$servicename.'\' '.($detected_value ? 'has been' : 'has not been').' detected ('.($current_state ? 'strongly recommended, currently enabled' : 'currently disabled').') do you want to '.($detected_value ? 'enable and configure' : 'disable').' it? ', array('yes', 'no'), ($current_state ? 'yes' : 'no'), 'svc_detect_change_'.$servicename) == 'yes') return $detected_value;
-		else return $current_state;
+		$answer = $inst->simple_query('Service \''.$servicename.'\' '.($detected_value ? 'has been' : 'has not been').' detected ('.($current_state ? 'strongly recommended, currently enabled' : 'currently disabled').') do you want to '.($detected_value ? 'enable and configure' : 'disable').' it? ', array('yes', 'no'), ($current_state ? 'yes' : 'no'), 'svc_detect_change_'.$servicename)
+		if ($answer == 'yes') return $detected_value;
+		else {
+			if ($servicename == 'web_server') echo "If ISPConfig-Panel is installed on this Server we will configure the Web Server anyways but will not enable it in ISPConfig.\n";
+			return $current_state;
+		}
 	} else return $current_state;
 }
 
diff --git a/install/update.php b/install/update.php
index 6cd18a3109..0012b7ed86 100644
--- a/install/update.php
+++ b/install/update.php
@@ -316,6 +316,13 @@ $conf['services']['vserver'] = check_service_config_state('vserver_server', $con
 $conf['services']['db'] = check_service_config_state('db_server', true); /* Will always offer as MySQL is of course installed on this host as it's a requirement for ISPC to work... */
 unset($current_svc_config);
 
+//** Is the ISPConfg Panel installed on this host? This might partially override user's preferences later.
+if($conf['apache']['installed'] == true){
+	if(!is_file($conf['apache']['vhost_conf_dir'].'/ispconfig.vhost')) $inst->install_ispconfig_interface = false;
+}
+if($conf['nginx']['installed'] == true){
+	if(!is_file($conf['nginx']['vhost_conf_dir'].'/ispconfig.vhost')) $inst->install_ispconfig_interface = false;
+}
 
 //** Shall the services be reconfigured during update
 $reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes', 'no', 'selected'), 'yes','reconfigure_services');
@@ -391,7 +398,7 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel
 		}
 	}
 
-	if($conf['services']['web']) {
+	if($conf['services']['web'] || $inst->install_ispconfig_interface) {
 
 		if($conf['pureftpd']['installed'] == true && $inst->reconfigure_app('Pureftpd', $reconfigure_services_answer)) {
 			//** Configure Pureftpd
@@ -462,14 +469,8 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel
 
 //** Configure ISPConfig
 swriteln('Updating ISPConfig');
-if($conf['apache']['installed'] == true){
-	if(!is_file($conf['apache']['vhost_conf_dir'].'/ispconfig.vhost')) $inst->install_ispconfig_interface = false;
-}
-if($conf['nginx']['installed'] == true){
-	if(!is_file($conf['nginx']['vhost_conf_dir'].'/ispconfig.vhost')) $inst->install_ispconfig_interface = false;
-}
 
-if ($conf['services']['web'] && $inst->install_ispconfig_interface) {
+if ($inst->install_ispconfig_interface) {
 	//** Customise the port ISPConfig runs on
 	$ispconfig_port_number = get_ispconfig_port_number();
 	if($autoupdate['ispconfig_port'] == 'default') $autoupdate['ispconfig_port'] = $ispconfig_port_number;
-- 
GitLab