Commit 570dc611 authored by grisel-davy's avatar grisel-davy

verifie si il y a besoin de regénérer

parent dac9cca9
......@@ -25,22 +25,30 @@ client_hostname = socket.gethostname().split('.', 1)[0]
all_users = api_client.list("mail/alias")
# Création de l'environnement Jinja
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template('templates/list')
aliases_rendered = template.render(data=all_users)
fichier = open('generated/aliases','w')
def generate(api_client):
# Création de l'environnement Jinja
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template('templates/list')
aliases_rendered = template.render(data=all_users)
if os.path.isfile('aliases_local'): # if a local aliases file exist, add it's content at the beginning
local = open('aliases_local','r')
for line in local.readlines():
fichier.write(line)
local.close()
fichier = open('generated/aliases','w')
fichier.write(aliases_rendered)
fichier.close()
if os.path.isfile('aliases_local'): # if a local aliases file exist, add it's content at the beginning
local = open('aliases_local','r')
for line in local.readlines():
fichier.write(line)
local.close()
fichier.write(aliases_rendered)
fichier.close()
call(["newalias", "generated/aliases"]) # Update the aliases config file
call(["postfix", "reload"]) # force the reloading now
call(["newalias", "generated/aliases"]) # Update the aliases config file
call(["postfix", "reload"]) # force the reloading now
for service in api_client.list("services/regen/"):
if service['hostname'] == client_hostname and \
service['service_name'] == 'mail-server' and \
service['need_regen']:
generate(api_client)
api_client.patch(service['api_url'], data={'need_regen': False})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment