From c0e34e960a15b9d610731a98e5957d872cd23090 Mon Sep 17 00:00:00 2001 From: Kload Date: Mon, 8 Jul 2013 14:18:44 +0200 Subject: [PATCH] Check domain BEFORE postinstall --- yunohost_tools.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yunohost_tools.py b/yunohost_tools.py index 9c956184..b8f18056 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -230,6 +230,16 @@ def tools_postinstall(domain, password, dyndns=False): 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: try: with open('/etc/yunohost/installed') as f: pass