diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php index acc00517945e6385c0c9f94f4aed6318f6a4ab51..d785caf2c5826b0bfabf07280caf4f1c11859845 100644 --- a/install/lib/update.lib.php +++ b/install/lib/update.lib.php @@ -418,4 +418,31 @@ function setDefaultServers(){ } + + +/** Checks if a detected service differs from db setup and asks the user what to do + * @param $servicename string the name of the Database-Field in "servers" for this service + * @param $detected_value boolean The result of service detection + */ +function check_service_config_state($servicename, $detected_value) { + global $current_svc_config, $inst; + + if ($current_svc_config[$servicename] == 1) $current_state = true; + else $current_state = false; + + if ($detected_value != $current_state) { + if ($detected_value) { + $svcdetect_state1 = 'has been'; + $svcdetect_state2 = 'configure'; + $svcdetect_defaultanswer = 'no'; + } else { + $svcdetect_state1 = 'has not been'; + $svcdetect_state2 = '(strongly recommended) disable'; + $svcdetect_defaultanswer = 'yes'; + } + if ($inst->simple_query('Service \''.$servicename.'\' '.$svcdetect_state1.' detected do you want to '.$svcdetect_state2.' it? ', array('yes', 'no'), $svcdetect_defaultanswer, 'svc_detect_change_'.$servicename) == 'yes') return $detected_value; + else return $current_state; + } else return $current_state; +} + ?> diff --git a/install/update.php b/install/update.php index 4626b5044e91147c954410eb32ef8100d5d33821..49953c35d7b057fb7b36260125e9da009ae9d34d 100644 --- a/install/update.php +++ b/install/update.php @@ -304,12 +304,15 @@ if($reconfigure_master_database_rights_answer == 'yes') { //** Detect the installed applications $inst->find_installed_apps(); -$conf['services']['mail'] = $conf['postfix']['installed']; -if ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']) $conf['services']['dns'] = true; -if ($conf['apache']['installed'] || $conf['nginx']['installed']) $conf['services']['web'] = true; -$conf['services']['xmpp'] = $conf['xmpp']['installed'];; -if ($conf['ufw']['installed'] || $conf['firewall']['installed']) $conf['services']['firewall'] = true; -$conf['services']['vserver'] = $conf['services']['vserver']; +//** Check for current service config state and compare to our results +$current_svc_config = $inst->dbmaster->queryOneRecord("SELECT * FROM `server` WHERE server_id=?", $conf['server_id']); +$conf['postfix']['installed'] = check_service_config_state('mail_server', $conf['postfix']['installed']); +$conf['services']['dns'] = check_service_config_state('dns_server', ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed'])); +$conf['services']['web'] = check_service_config_state('web_server', ($conf['apache']['installed'] || $conf['nginx']['installed'])); +$conf['services']['xmpp'] = check_service_config_state('xmpp_server', $conf['xmpp']['installed']); +$conf['services']['firewall'] = check_service_config_state('firewall_server', ($conf['ufw']['installed'] || $conf['firewall']['installed'])); +$conf['services']['vserver'] = check_service_config_state('vserver_server', $conf['services']['vserver']); +//** vv is this intended??? If you want to check adapt the lines above... vv $conf['services']['db'] = true;