mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge branch 'dev' of https://github.com/YunoHost/moulinette into dev_beudbeud
This commit is contained in:
commit
c8ff022881
2 changed files with 35 additions and 1 deletions
|
@ -64,7 +64,10 @@ Specifications
|
||||||
|
|
||||||
### Monitoring
|
### Monitoring
|
||||||
|
|
||||||
yunohost monitor info #FIX
|
yunohost monitor info [-h] [-u] [-d] [-p] [-c] [-m] [-i]
|
||||||
|
yunohost monitor process [-h] [-e PROCESS] [-d PROCESS]
|
||||||
|
[--stop PROCESS] [-c PORT] [-i]
|
||||||
|
[--start PROCESS]
|
||||||
|
|
||||||
|
|
||||||
### Tools
|
### Tools
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import datetime
|
||||||
|
import requests
|
||||||
from yunohost import YunoHostError, win_msg, colorize, validate, get_required_args
|
from yunohost import YunoHostError, win_msg, colorize, validate, get_required_args
|
||||||
|
|
||||||
def domain_list(args, connections):
|
def domain_list(args, connections):
|
||||||
|
@ -51,6 +53,10 @@ def domain_add(args, connections):
|
||||||
"""
|
"""
|
||||||
yldap = connections['ldap']
|
yldap = connections['ldap']
|
||||||
attr_dict = { 'objectClass' : ['mailDomain', 'top'] }
|
attr_dict = { 'objectClass' : ['mailDomain', 'top'] }
|
||||||
|
request_ip = requests.get('http://ip.yunohost.org')
|
||||||
|
ip = str(request_ip.text)
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
timestamp = str(now.year) + str(now.month) + str(now.day)
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
args = get_required_args(args, { 'domain' : _('New domain') })
|
args = get_required_args(args, { 'domain' : _('New domain') })
|
||||||
|
@ -61,6 +67,27 @@ def domain_add(args, connections):
|
||||||
validate({ domain : r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' })
|
validate({ domain : r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' })
|
||||||
yldap.validate_uniqueness({ 'virtualdomain' : domain })
|
yldap.validate_uniqueness({ 'virtualdomain' : domain })
|
||||||
attr_dict['virtualdomain'] = domain
|
attr_dict['virtualdomain'] = domain
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open('/var/lib/bind/'+ domain +'.zone') as f: pass
|
||||||
|
except IOError as e:
|
||||||
|
zone_lines = [
|
||||||
|
'$TTL 38400',
|
||||||
|
domain +'. IN SOA ns.'+ domain +'. root.'+ domain +'. '+ timestamp +' 10800 3600 604800 38400',
|
||||||
|
domain +'. IN NS ns.'+ domain +'.',
|
||||||
|
domain +'. IN A '+ ip,
|
||||||
|
domain +'. IN MX 5 mail.'+ domain +'.',
|
||||||
|
domain +'. IN TXT "v=spf1 a mx a:'+ domain +' ?all"',
|
||||||
|
'mail.'+ domain +'. IN A '+ ip,
|
||||||
|
'ns.'+ domain +'. IN A '+ ip,
|
||||||
|
'root.'+ domain +'. IN A '+ ip
|
||||||
|
]
|
||||||
|
with open('/var/lib/bind/' + domain + '.zone', 'w') as zone:
|
||||||
|
for line in zone_lines:
|
||||||
|
zone.write(line + '\n')
|
||||||
|
else:
|
||||||
|
raise YunoHostError(17, _("Zone file already exists for ") + domain)
|
||||||
|
|
||||||
if yldap.add('virtualdomain=' + domain + ',ou=domains', attr_dict):
|
if yldap.add('virtualdomain=' + domain + ',ou=domains', attr_dict):
|
||||||
result.append(domain)
|
result.append(domain)
|
||||||
continue
|
continue
|
||||||
|
@ -93,6 +120,10 @@ def domain_remove(args, connections):
|
||||||
for domain in args['domain']:
|
for domain in args['domain']:
|
||||||
validate({ domain : r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' })
|
validate({ domain : r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' })
|
||||||
if yldap.remove('virtualdomain=' + domain + ',ou=domains'):
|
if yldap.remove('virtualdomain=' + domain + ',ou=domains'):
|
||||||
|
try:
|
||||||
|
os.remove('/var/lib/bind/'+ domain +'.zone')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
result.append(domain)
|
result.append(domain)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue