Skip to content

Commit bd494ec

Browse files
author
A. Täffner
committed
uüdater: implemented request on new/vanished service detection
1 parent 83e5ef3 commit bd494ec

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

install/lib/update.lib.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,31 @@ function setDefaultServers(){
418418

419419
}
420420

421+
422+
423+
/** Checks if a detected service differs from db setup and asks the user what to do
424+
* @param $servicename string the name of the Database-Field in "servers" for this service
425+
* @param $detected_value boolean The result of service detection
426+
*/
427+
function check_service_config_state($servicename, $detected_value) {
428+
global $current_svc_config, $inst;
429+
430+
if ($current_svc_config[$servicename] == 1) $current_state = true;
431+
else $current_state = false;
432+
433+
if ($detected_value != $current_state) {
434+
if ($detected_value) {
435+
$svcdetect_state1 = 'has been';
436+
$svcdetect_state2 = 'configure';
437+
$svcdetect_defaultanswer = 'no';
438+
} else {
439+
$svcdetect_state1 = 'has not been';
440+
$svcdetect_state2 = '(strongly recommended) disable';
441+
$svcdetect_defaultanswer = 'yes';
442+
}
443+
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;
444+
else return $current_state;
445+
} else return $current_state;
446+
}
447+
421448
?>

install/update.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,15 @@
304304
//** Detect the installed applications
305305
$inst->find_installed_apps();
306306

307-
$conf['services']['mail'] = $conf['postfix']['installed'];
308-
if ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']) $conf['services']['dns'] = true;
309-
if ($conf['apache']['installed'] || $conf['nginx']['installed']) $conf['services']['web'] = true;
310-
$conf['services']['xmpp'] = $conf['xmpp']['installed'];;
311-
if ($conf['ufw']['installed'] || $conf['firewall']['installed']) $conf['services']['firewall'] = true;
312-
$conf['services']['vserver'] = $conf['services']['vserver'];
307+
//** Check for current service config state and compare to our results
308+
$current_svc_config = $inst->dbmaster->queryOneRecord("SELECT * FROM `server` WHERE server_id=?", $conf['server_id']);
309+
$conf['postfix']['installed'] = check_service_config_state('mail_server', $conf['postfix']['installed']);
310+
$conf['services']['dns'] = check_service_config_state('dns_server', ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']));
311+
$conf['services']['web'] = check_service_config_state('web_server', ($conf['apache']['installed'] || $conf['nginx']['installed']));
312+
$conf['services']['xmpp'] = check_service_config_state('xmpp_server', $conf['xmpp']['installed']);
313+
$conf['services']['firewall'] = check_service_config_state('firewall_server', ($conf['ufw']['installed'] || $conf['firewall']['installed']));
314+
$conf['services']['vserver'] = check_service_config_state('vserver_server', $conf['services']['vserver']);
315+
//** vv is this intended??? If you want to check adapt the lines above... vv
313316
$conf['services']['db'] = true;
314317

315318

0 commit comments

Comments
 (0)