[fix] Add domain only if needed on main domain change #19

This commit is contained in:
Jérôme Lebleu 2014-07-22 16:10:19 +02:00
parent 8f1dd4b5e3
commit 4d2c6bfb64
3 changed files with 8 additions and 3 deletions

View file

@ -112,6 +112,7 @@
"password_too_short" : "Password is too short",
"admin_password_change_failed" : "Unable to change password",
"admin_password_changed" : "Administration password successfully changed",
"new_domain_required" : "You must provide the new main domain",
"maindomain_change_failed" : "Unable to change main domain",
"maindomain_changed" : "Main domain successfully changed",
"yunohost_installing" : "Installing YunoHost...",

View file

@ -112,6 +112,7 @@
"password_too_short" : "Le mot de passe est trop court",
"admin_password_change_failed" : "Impossible de modifier le mot de passe d'administration",
"admin_password_changed" : "Mot de passe d'administration modifié avec succès",
"new_domain_required" : "Vous devez spécifier le nouveau domaine principal",
"maindomain_change_failed" : "Impossible de modifier le domaine principal",
"maindomain_changed" : "Domaine principal modifié avec succès",
"yunohost_installing" : "Installation de YunoHost...",

View file

@ -107,7 +107,7 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
old_domain
"""
from yunohost.domain import domain_add
from yunohost.domain import domain_add, domain_list
from yunohost.dyndns import dyndns_subscribe
if not old_domain:
@ -117,6 +117,11 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
if not new_domain:
return { 'current_main_domain': old_domain }
if not new_domain:
raise MoulinetteError(errno.EINVAL, m18n.n('new_domain_required'))
if new_domain not in domain_list(auth)['domains']:
domain_add(auth, new_domain, main=True)
config_files = [
'/etc/postfix/main.cf',
'/etc/metronome/metronome.cfg.lua',
@ -140,8 +145,6 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
for line in lines:
sources.write(re.sub(r''+ old_domain +'', new_domain, line))
domain_add(auth, new_domain, main=True)
os.system('rm /etc/ssl/private/yunohost_key.pem')
os.system('rm /etc/ssl/certs/yunohost_crt.pem')