Added some functionality
This commit is contained in:
parent
f653a20d35
commit
8814127cf8
45
malias.py
45
malias.py
@ -128,7 +128,7 @@ def apikey(key):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
|
||||||
def get_mail_domains():
|
def get_mail_domains(info):
|
||||||
apikey = get_api()
|
apikey = get_api()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
mail_server = get_settings('mail_server')
|
mail_server = get_settings('mail_server')
|
||||||
@ -138,18 +138,20 @@ def get_mail_domains():
|
|||||||
current = urllib.request.urlopen(req)
|
current = urllib.request.urlopen(req)
|
||||||
remote = current.read().decode('utf-8')
|
remote = current.read().decode('utf-8')
|
||||||
remoteData = json.loads(remote)
|
remoteData = json.loads(remote)
|
||||||
total_aliases = 0
|
if info:
|
||||||
i=0
|
total_aliases = 0
|
||||||
print('\n[b]malias[/b] - All email domains on %s' %(mail_server))
|
i=0
|
||||||
print('==================================================================')
|
print('\n[b]malias[/b] - All email domains on %s' %(mail_server))
|
||||||
for domains in remoteData:
|
print('==================================================================')
|
||||||
cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', ('%'+remoteData[i]['domain_name']+'%','%'+remoteData[i]['domain_name']+'%',))
|
for domains in remoteData:
|
||||||
count = cursor.fetchone()[0]
|
cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', ('%'+remoteData[i]['domain_name']+'%','%'+remoteData[i]['domain_name']+'%',))
|
||||||
total_aliases += count
|
count = cursor.fetchone()[0]
|
||||||
print('%s \t\twith %s aliases' %(remoteData[i]['domain_name'],count))
|
total_aliases += count
|
||||||
i+=1
|
print('%s \t\twith %s aliases' %(remoteData[i]['domain_name'],count))
|
||||||
print('\n\nThere is a total of %s domains with %s aliases.' %(str(i),str(total_aliases)))
|
i+=1
|
||||||
|
print('\n\nThere is a total of %s domains with %s aliases.' %(str(i),str(total_aliases)))
|
||||||
|
else:
|
||||||
|
return(remoteData)
|
||||||
|
|
||||||
|
|
||||||
def create(alias,to_address):
|
def create(alias,to_address):
|
||||||
@ -440,18 +442,27 @@ def show_current_info():
|
|||||||
aliases_server = number_of_aliases_on_server()
|
aliases_server = number_of_aliases_on_server()
|
||||||
alias_db = number_of_aliases_in_db()
|
alias_db = number_of_aliases_in_db()
|
||||||
mailcow_version = get_mailcow_version()
|
mailcow_version = get_mailcow_version()
|
||||||
|
mail_domains = get_mail_domains(False)
|
||||||
|
domain = ""
|
||||||
|
i=0
|
||||||
|
for domains in mail_domains:
|
||||||
|
if i!=0:
|
||||||
|
domain = domain + ', ' + str(mail_domains[i]['domain_name'])
|
||||||
|
else:
|
||||||
|
domain = domain + str(mail_domains[i]['domain_name'])
|
||||||
|
i+=1
|
||||||
print('\n[b]malias[/b] - Manage aliases on mailcow Instance.')
|
print('\n[b]malias[/b] - Manage aliases on mailcow Instance.')
|
||||||
print('===================================================')
|
print('===================================================')
|
||||||
print('API key : [b]%s[/b]' % (API))
|
print('API key : [b]%s[/b]' % (API))
|
||||||
print('mailcow Instance : [b]%s[/b]' % (mail_server))
|
print('Mailcow Instance : [b]%s[/b]' % (mail_server))
|
||||||
|
print('Active domains : [b]%s[/b]' % (domain))
|
||||||
print('Mailcow version : [b]%s[/b]' % (mailcow_version))
|
print('Mailcow version : [b]%s[/b]' % (mailcow_version))
|
||||||
print('Logfile : [b]%s[/b]' % (logfile))
|
print('Logfile : [b]%s[/b]' % (logfile))
|
||||||
print('Databse : [b]%s[b]' % (database))
|
print('Databse : [b]%s[b]' % (database))
|
||||||
print('Aliases on server : [b]%s[/b]' % (aliases_server))
|
print('Aliases on server : [b]%s[/b]' % (aliases_server))
|
||||||
print('Aliases in DB : [b]%s[/b]' % (alias_db))
|
print('Aliases in DB : [b]%s[/b]' % (alias_db))
|
||||||
print('')
|
print('')
|
||||||
print('App version : [b]%s[/b] (https://iurl.no/malias)' % (app_version))
|
print('App version : [b]%s[/b] (https://gitlab.pm/rune/malias)' % (app_version))
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
|
|
||||||
@ -512,7 +523,7 @@ elif args['copy']:
|
|||||||
elif args['list']:
|
elif args['list']:
|
||||||
list_alias()
|
list_alias()
|
||||||
elif args['domains']:
|
elif args['domains']:
|
||||||
get_mail_domains()
|
get_mail_domains(True)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user