Skip to content

Commit ec1ea49

Browse files
author
Till Brehm
committed
Merge branch 'updater-interactive-service-config' into 'stable-3.1'
Updater interactive service config I hope this is okay for you. Please have a quick look at docs/autoinstall_samples/autoinstall.ini.sample if that syntax is okay. This MR closes ispconfig/ispconfig3#4163 and also closes ispconfig/ispconfig3#4050 Tested on Master-Slave and confirmed working on both. See comments. See merge request !431
2 parents b05d19a + 7bba85e commit ec1ea49

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

docs/autoinstall_samples/autoinstall.conf_sample.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@
4949
$autoupdate['ispconfig_port'] = '8080'; // default: 8080
5050
$autoupdate['create_new_ispconfig_ssl_cert'] = 'no'; // no (default), yes
5151
$autoupdate['reconfigure_crontab'] = 'yes'; // yes (default), no
52+
53+
/* These are for service-detection (defaulting to old behaviour where alle changes were automatically accepted) */
54+
$autoupdate['svc_detect_change_mail_server'] = 'yes'; // yes (default), no
55+
$autoupdate['svc_detect_change_web_server'] = 'yes'; // yes (default), no
56+
$autoupdate['svc_detect_change_dns_server'] = 'yes'; // yes (default), no
57+
$autoupdate['svc_detect_change_xmpp_server'] = 'yes'; // yes (default), no
58+
$autoupdate['svc_detect_change_firewall_server'] = 'yes'; // yes (default), no
59+
$autoupdate['svc_detect_change_vserver_server'] = 'yes'; // yes (default), no
60+
$autoupdate['svc_detect_change_db_server'] = 'yes'; // yes (default), no
61+
5262
?>

docs/autoinstall_samples/autoinstall.ini.sample

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,13 @@ reconfigure_permissions_in_master_database=no
4747
reconfigure_services=yes
4848
ispconfig_port=8080
4949
create_new_ispconfig_ssl_cert=no
50-
reconfigure_crontab=yes
50+
reconfigure_crontab=yes
51+
52+
; These are for service-detection (defaulting to old behaviour where alle changes were automatically accepted)
53+
svc_detect_change_mail_server=yes
54+
svc_detect_change_web_server=yes
55+
svc_detect_change_dns_server=yes
56+
svc_detect_change_xmpp_server=yes
57+
svc_detect_change_firewall_server=yes
58+
svc_detect_change_vserver_server=yes
59+
svc_detect_change_db_server=yes

install/lib/update.lib.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,22 @@ 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, $conf;
429+
430+
if ($current_svc_config[$servicename] == 1) $current_state = 1;
431+
else $current_state = 0;
432+
433+
if ($detected_value != $current_state) {
434+
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;
435+
else return $current_state;
436+
} else return $current_state;
437+
}
438+
421439
?>

install/update.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,18 @@
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+
if ($conf['mysql']['master_slave_setup'] == 'y') $current_svc_config = $inst->dbmaster->queryOneRecord("SELECT mail_server,web_server,dns_server,xmpp_server,firewall_server,vserver_server,db_server FROM ?? WHERE server_id=?", $conf['mysql']['master_database'] . '.server', $conf['server_id']);
309+
else $current_svc_config = $inst->db->queryOneRecord("SELECT mail_server,web_server,dns_server,xmpp_server,firewall_server,vserver_server,db_server FROM ?? WHERE server_id=?", $conf["mysql"]["database"] . '.server', $conf['server_id']);
310+
$conf['postfix']['installed'] = check_service_config_state('mail_server', $conf['postfix']['installed']);
311+
$conf['services']['dns'] = check_service_config_state('dns_server', ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']));
312+
$conf['services']['web'] = check_service_config_state('web_server', ($conf['apache']['installed'] || $conf['nginx']['installed']));
313+
$conf['services']['xmpp'] = check_service_config_state('xmpp_server', $conf['xmpp']['installed']);
314+
$conf['services']['firewall'] = check_service_config_state('firewall_server', ($conf['ufw']['installed'] || $conf['firewall']['installed']));
315+
$conf['services']['vserver'] = check_service_config_state('vserver_server', $conf['services']['vserver']);
316+
//** vv is this intended??? If you want to check adapt the lines above... vv
313317
$conf['services']['db'] = true;
318+
unset($current_svc_config);
314319

315320

316321
//** Shall the services be reconfigured during update

0 commit comments

Comments
 (0)