Check domain BEFORE postinstall

This commit is contained in:
Kload 2013-07-08 14:18:44 +02:00
parent 9b20bb7ef1
commit c0e34e960a

View file

@ -230,6 +230,16 @@ def tools_postinstall(domain, password, dyndns=False):
password -- YunoHost admin password password -- YunoHost admin password
""" """
if len(domain.split('.')) >= 3:
r = requests.get('http://dyndns.yunohost.org/domains')
dyndomains = json.loads(r.text)
dyndomain = '.'.join(new_domain.split('.')[1:])
if dyndomain in dyndomains:
if requests.get('http://dyndns.yunohost.org/test/'+ domain).status_code == 200:
dyndns=True
else:
raise YunoHostError(17, _("Domain is already taken"))
with YunoHostLDAP(password='yunohost') as yldap: with YunoHostLDAP(password='yunohost') as yldap:
try: try:
with open('/etc/yunohost/installed') as f: pass with open('/etc/yunohost/installed') as f: pass