Skip to content

Commit b149a44

Browse files
author
Marius Burkard
committed
Merge branch '5847-updater-check-for-templates' into 'develop'
check for conf-custom templates during update Closes #5847 See merge request ispconfig/ispconfig3!1286
2 parents f4547c1 + ab74ee2 commit b149a44

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

install/lib/update.lib.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,49 @@ function check_service_config_state($servicename, $detected_value) {
459459
} else return $current_state;
460460
}
461461

462+
/**
463+
* Check for existing conf-custom templates and offer to rename them.
464+
*/
465+
function checkAndRenameCustomTemplates($default_prompt='no') {
466+
global $inst;
467+
$ret = true;
468+
469+
$default_prompt = ($default_prompt == 'yes') ? 'yes' : 'no';
470+
471+
$template_directories = array(
472+
'/usr/local/ispconfig/server/conf-custom',
473+
'/usr/local/ispconfig/server/conf-custom/install',
474+
);
475+
476+
$found_templates = array();
477+
foreach ($template_directories as $dir) {
478+
if (!is_dir($dir)) { continue; }
479+
foreach (glob("$dir/*.master") as $f) {
480+
if (is_file($f)) {
481+
$found_templates[] = $f;
482+
}
483+
}
484+
}
485+
486+
if (count($found_templates) > 0) {
487+
echo "The following custom templates were found:\n\n";
488+
echo implode("\n", $found_templates) . "\n\n";
489+
490+
$answer = $inst->simple_query('Do you want to rename these conf-custom templates now so the default templates are used?', array('yes', 'no'), $default_prompt, 'rename_custom_templates');
491+
if (strtolower($answer) == 'yes') {
492+
$date=date('-Y-m-d_H-i');
493+
foreach ($found_templates as $f) {
494+
if (!rename($f, $f.$date)) {
495+
echo "Error renaming template $f\n";
496+
$ret = false;
497+
}
498+
}
499+
} else {
500+
$ret = null;
501+
}
502+
}
503+
504+
return $ret;
505+
}
506+
462507
?>

install/update.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@
370370

371371
if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'selected') {
372372

373+
checkAndRenameCustomTemplates();
374+
373375
if($conf['services']['mail']) {
374376

375377
//** Configure postfix
@@ -483,10 +485,10 @@
483485

484486
}
485487

486-
if($conf['services']['xmpp'] && $inst->reconfigure_app('XMPP', $reconfigure_services_answer)) {
487-
//** Configure Metronome XMPP
488-
$inst->configure_xmpp('dont-create-certs');
489-
}
488+
if($conf['services']['xmpp'] && $inst->reconfigure_app('XMPP', $reconfigure_services_answer)) {
489+
//** Configure Metronome XMPP
490+
$inst->configure_xmpp('dont-create-certs');
491+
}
490492

491493
if($conf['services']['firewall'] && $inst->reconfigure_app('Firewall', $reconfigure_services_answer)) {
492494
if($conf['ufw']['installed'] == true) {

0 commit comments

Comments
 (0)