diff --git a/locales/en.json b/locales/en.json index c1d4d9a39..6c6c8f277 100644 --- a/locales/en.json +++ b/locales/en.json @@ -216,10 +216,11 @@ "service_conf_file_copy_failed": "Unable to copy the new configuration file '{new}' to '{conf}'", "service_conf_file_manually_modified": "The configuration file '{conf}' has been manually modified and will not be updated", "service_conf_file_manually_removed": "The configuration file '{conf}' has been manually removed and will not be created", - "service_conf_file_not_managed": "The configuration file '{conf}' is not managed yet and will not be updated", "service_conf_file_remove_failed": "Unable to remove the configuration file '{conf}'", "service_conf_file_removed": "The configuration file '{conf}' has been removed", "service_conf_file_updated": "The configuration file '{conf}' has been updated", + "service_conf_new_managed_file": "The configuration file '{conf}' is now managed by the service {service}.", + "service_conf_file_kept_back": "The configuration file '{conf}' is expected to be deleted by service {service} but has been kept back.", "service_conf_up_to_date": "The configuration is already up-to-date for service '{service}'", "service_conf_updated": "The configuration has been updated for service '{service}'", "service_conf_would_be_updated": "The configuration would have been updated for service '{service}'", diff --git a/src/yunohost/service.py b/src/yunohost/service.py index e64c9cd89..91e654f0b 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -391,15 +391,21 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False, logger.debug("> no changes to system conf has been made") conf_status = 'managed' regenerated = True - elif force and to_remove: + elif not to_remove: + # If the conf exist but is not managed yet, and is not to be removed, + # we assume that it is safe to regen it, since the file is backuped + # anyway (by default in _regen), as long as we warn the user + # appropriately. + logger.warning(m18n.n('service_conf_new_managed_file', + conf=system_path, service=service)) + regenerated = _regen(system_path, pending_path) + conf_status = 'new' + elif force: regenerated = _regen(system_path) conf_status = 'force-removed' - elif force: - regenerated = _regen(system_path, pending_path) - conf_status = 'force-updated' else: - logger.warning(m18n.n('service_conf_file_not_managed', - conf=system_path)) + logger.warning(m18n.n('service_conf_file_kept_back', + conf=system_path, service=service)) conf_status = 'unmanaged' # -> system conf has not been manually modified elif system_hash == saved_hash: