Commit d5a0f240 authored by Jesse Norell's avatar Jesse Norell
Browse files

check for conf-custom templates during update

parent f4547c19
......@@ -459,4 +459,51 @@ function check_service_config_state($servicename, $detected_value) {
} else return $current_state;
}
/**
* Check for existing conf-custom templates and offer to rename them.
*/
function checkAndRenameCustomTemplates($default_prompt='no') {
global $inst;
$ret = true;
$default_prompt = ($default_prompt == 'yes') ? 'yes' : 'no';
$template_directories = array(
'/usr/local/ispconfig/server/conf-custom',
'/usr/local/ispconfig/server/conf-custom/install',
);
$found_templates = array();
foreach ($template_directories as $dir) {
if (!is_dir($dir)) { continue; }
$output = array();
exec("find $dir -maxdepth 1 -name \*.master", $output);
foreach ($output as $f) {
if (is_file(trim($f))) {
$found_templates[] = trim($f);
}
}
}
if (count($found_templates) > 0) {
echo "The following custom templates were found:\n\n";
echo implode("\n", $found_templates) . "\n\n";
$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');
if (strtolower($answer) == 'yes') {
$date=date('-Y-m-d_H-i');
foreach ($found_templates as $f) {
if (!rename($f, $f.$date)) {
echo "Error renaming template $f\n";
$ret = false;
}
}
} else {
$ret = null;
}
}
return $ret;
}
?>
......@@ -370,6 +370,8 @@ $reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', arra
if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'selected') {
checkAndRenameCustomTemplates();
if($conf['services']['mail']) {
//** Configure postfix
......@@ -483,10 +485,10 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel
}
if($conf['services']['xmpp'] && $inst->reconfigure_app('XMPP', $reconfigure_services_answer)) {
//** Configure Metronome XMPP
$inst->configure_xmpp('dont-create-certs');
}
if($conf['services']['xmpp'] && $inst->reconfigure_app('XMPP', $reconfigure_services_answer)) {
//** Configure Metronome XMPP
$inst->configure_xmpp('dont-create-certs');
}
if($conf['services']['firewall'] && $inst->reconfigure_app('Firewall', $reconfigure_services_answer)) {
if($conf['ufw']['installed'] == true) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment