verifie si il y a besoin de regénérer
This commit is contained in:
parent
dac9cca994
commit
570dc611d4
1 changed files with 22 additions and 14 deletions
10
main.py
Executable file → Normal file
10
main.py
Executable file → Normal file
|
@ -25,6 +25,8 @@ client_hostname = socket.gethostname().split('.', 1)[0]
|
|||
|
||||
all_users = api_client.list("mail/alias")
|
||||
|
||||
|
||||
def generate(api_client):
|
||||
# Création de l'environnement Jinja
|
||||
env = Environment(loader=FileSystemLoader('.'))
|
||||
template = env.get_template('templates/list')
|
||||
|
@ -41,6 +43,12 @@ if os.path.isfile('aliases_local'): # if a local aliases file exist, add it's c
|
|||
fichier.write(aliases_rendered)
|
||||
fichier.close()
|
||||
|
||||
|
||||
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})
|
||||
|
|
Loading…
Reference in a new issue