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()
|
||||
|
||||
|
||||
def get_mail_domains():
|
||||
def get_mail_domains(info):
|
||||
apikey = get_api()
|
||||
cursor = conn.cursor()
|
||||
mail_server = get_settings('mail_server')
|
||||
@ -138,18 +138,20 @@ def get_mail_domains():
|
||||
current = urllib.request.urlopen(req)
|
||||
remote = current.read().decode('utf-8')
|
||||
remoteData = json.loads(remote)
|
||||
total_aliases = 0
|
||||
i=0
|
||||
print('\n[b]malias[/b] - All email domains on %s' %(mail_server))
|
||||
print('==================================================================')
|
||||
for domains in remoteData:
|
||||
cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', ('%'+remoteData[i]['domain_name']+'%','%'+remoteData[i]['domain_name']+'%',))
|
||||
count = cursor.fetchone()[0]
|
||||
total_aliases += count
|
||||
print('%s \t\twith %s aliases' %(remoteData[i]['domain_name'],count))
|
||||
i+=1
|
||||
print('\n\nThere is a total of %s domains with %s aliases.' %(str(i),str(total_aliases)))
|
||||
|
||||
if info:
|
||||
total_aliases = 0
|
||||
i=0
|
||||
print('\n[b]malias[/b] - All email domains on %s' %(mail_server))
|
||||
print('==================================================================')
|
||||
for domains in remoteData:
|
||||
cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', ('%'+remoteData[i]['domain_name']+'%','%'+remoteData[i]['domain_name']+'%',))
|
||||
count = cursor.fetchone()[0]
|
||||
total_aliases += count
|
||||
print('%s \t\twith %s aliases' %(remoteData[i]['domain_name'],count))
|
||||
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):
|
||||
@ -440,18 +442,27 @@ def show_current_info():
|
||||
aliases_server = number_of_aliases_on_server()
|
||||
alias_db = number_of_aliases_in_db()
|
||||
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('===================================================')
|
||||
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('Logfile : [b]%s[/b]' % (logfile))
|
||||
print('Databse : [b]%s[b]' % (database))
|
||||
print('Aliases on server : [b]%s[/b]' % (aliases_server))
|
||||
print('Aliases in DB : [b]%s[/b]' % (alias_db))
|
||||
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('')
|
||||
|
||||
|
||||
@ -512,7 +523,7 @@ elif args['copy']:
|
||||
elif args['list']:
|
||||
list_alias()
|
||||
elif args['domains']:
|
||||
get_mail_domains()
|
||||
get_mail_domains(True)
|
||||
|
||||
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user