supporting email redirections
This commit is contained in:
parent
5cf9299069
commit
bfd05cdb89
4 changed files with 262 additions and 2 deletions
20
main.py
20
main.py
|
@ -30,7 +30,9 @@ def generate(api_client):
|
|||
all_users = api_client.list("localemail/users")
|
||||
# Création de l'environnement Jinja
|
||||
env = Environment(loader=FileSystemLoader(path))
|
||||
template = env.get_template('templates/list')
|
||||
|
||||
# On commence par les alias
|
||||
template = env.get_template('templates/list_alias')
|
||||
aliases_rendered = template.render(data=all_users)
|
||||
|
||||
fichier = open(path+'/generated/aliases','w')
|
||||
|
@ -44,7 +46,23 @@ def generate(api_client):
|
|||
fichier.write(aliases_rendered)
|
||||
fichier.close()
|
||||
|
||||
# On enchaine avec les redirections
|
||||
template = env.get_template('templates/list_virtual')
|
||||
virtuals_rendered = template.render(data=all_users)
|
||||
|
||||
fichier = open(path+'/generated/virtual','w')
|
||||
|
||||
if os.path.isfile(path+'/virtuals_local'): # if a local aliases file exist, add it's content at the beginning
|
||||
local = open(path+'/virtuals_local','r')
|
||||
for line in local.readlines():
|
||||
fichier.write(line)
|
||||
local.close()
|
||||
|
||||
fichier.write(virtuals_rendered)
|
||||
fichier.close()
|
||||
|
||||
call(["/usr/bin/newaliases"], stdout=open(os.devnull, 'wb')) # Update the aliases config file
|
||||
call(["/usr/sbin/postmap", path+"/generated/virtual"], stdout=open(os.devnull, 'wb')) # Update the aliases config file
|
||||
call(["/usr/sbin/postfix", "reload"]) # force the reloading now
|
||||
|
||||
for arg in sys.argv:
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
{% for user in data -%}
|
||||
{%- for alias in user.email_address -%}
|
||||
{%- if user.local_email_redirect -%}
|
||||
{{ alias.local_part }}:{{ user.email }}
|
||||
{% else %}
|
||||
{{ alias.local_part }}:{{ alias.user }}
|
||||
{% endif %}
|
10
templates/list_virtual
Normal file
10
templates/list_virtual
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Liste d'association alias:addresse des users
|
||||
|
||||
|
||||
{% for user in data -%}
|
||||
{%- for alias in user.email_address -%}
|
||||
{%- if user.local_email_redirect -%}
|
||||
{{ alias.complete_email_address }} {{ user.email }}
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
{%- endfor -%}
|
233
virtuals_local
Normal file
233
virtuals_local
Normal file
|
@ -0,0 +1,233 @@
|
|||
# -*- coding: utf-8; mode: conf-space -*-
|
||||
#
|
||||
# Fichier gere par BCfg2
|
||||
#
|
||||
# Reecriture des addresses en @lists.crans.org pour les mailing-listes
|
||||
|
||||
# +----------+
|
||||
# | Alias ML |
|
||||
# +----------+
|
||||
|
||||
trophee@crans.org trophee@lists.crans.org
|
||||
contact@crans.org ca@lists.crans.org
|
||||
paypal@crans.org paypal@lists.crans.org
|
||||
nounous@crans.org nounou@lists.crans.org
|
||||
dsi-crans@crans.org dsi-crans@lists.crans.org
|
||||
dsi@crans.org crans-dsi@lists.crans.org
|
||||
respbat@crans.org respbats@lists.crans.org
|
||||
adhesion@crans.org respbats@lists.crans.org
|
||||
cableurs@crans.org respbats@lists.crans.org
|
||||
cableur@crans.org respbats@lists.crans.org
|
||||
nuitanormale2007@crans.org gala2007@lists.crans.org
|
||||
nuitanormale2005@crans.org cog@lists.crans.org
|
||||
nuitanormale@crans.org cog@lists.crans.org
|
||||
reservation@crans.org reservations@lists.crans.org
|
||||
cineclub@crans.org cine-club@lists.crans.org
|
||||
cine.club@crans.org cine-club@lists.crans.org
|
||||
club-piano-owner@crans.org club-piano-owner@lists.crans.org
|
||||
club-piano-bureau@crans.org club-piano-bureau@lists.crans.org
|
||||
club-moto@lists.crans.org arbrakam@lists.crans.org
|
||||
forum@crans.org forum@lists.crans.org
|
||||
forum@crans.ens-cachan.fr forum@lists.crans.org
|
||||
praccis@crans.org praccis@lists.crans.org
|
||||
crous-crans@crans.org crous-crans@lists.crans.org
|
||||
tresorier@crans.org tresorier@lists.crans.org
|
||||
respo-info.bde@crans.org respo-info.bde@lists.crans.org
|
||||
secretaire.bde@crans.org secretaire.bde@lists.crans.org
|
||||
notekfet2015@crans.org notekfet2015@lists.crans.org
|
||||
tresorerie.bde@crans.org tresorerie.bde@lists.crans.org
|
||||
admissible2015@crans.org admissible2015@lists.crans.org
|
||||
ups-avec-ses-etudiants@crans.org ups-avec-ses-etudiants@lists.crans.org
|
||||
achats@crans.org achats-crans@lists.crans.org
|
||||
tresorerie@crans.org tresorier@lists.crans.org
|
||||
tresorier.e.s@crans.org tresorier@lists.crans.org
|
||||
tresorier.e@crans.org tresorier@lists.crans.org
|
||||
tresoriers@crans.org tresorier@lists.crans.org
|
||||
|
||||
# +----------+
|
||||
# | trackers |
|
||||
# +----------+
|
||||
|
||||
bugs@crans.org bugs@lists.crans.org
|
||||
tracker@crans.org tracker@tracker.adm.crans.org
|
||||
|
||||
# +-------------+
|
||||
# | temporaires |
|
||||
# +-------------+
|
||||
|
||||
club-wrc@crans.org wrc@lists.crans.org
|
||||
club-cineclub-programme@crans.org programme-cineclub@lists.crans.org
|
||||
club-praccis@crans.org praccis@lists.crans.org
|
||||
club-lezard@crans.org lezard@lists.crans.org
|
||||
club-oensologie@crans.org oensologie@lists.crans.org
|
||||
club-sauce@crans.org lasauce@lists.crans.org
|
||||
club-dinos@crans.org dinos@lists.crans.org
|
||||
club-moto@crans.org arbrakam@lists.crans.org
|
||||
club-arbrakam@crans.org arbrakam@lists.crans.org
|
||||
arpej@lists.crans.org ca@lists.crans.org
|
||||
arpej@crans.org ca@lists.crans.org
|
||||
20ans@crans.org journees@federez.net
|
||||
|
||||
# +-----------------------------------------------------------------------+
|
||||
# | Compatibilite anciennes ML(@crans.org) -> nouvelles(@lists.crans.org) |
|
||||
# +-----------------------------------------------------------------------+
|
||||
|
||||
bureau@crans.org bureau@lists.crans.org
|
||||
nounou@crans.org nounou@lists.crans.org
|
||||
roots@crans.org roots@lists.crans.org
|
||||
respbats@crans.org respbats@lists.crans.org
|
||||
moderateurs@crans.org moderateurs@lists.crans.org
|
||||
disconnect@crans.org disconnect@lists.crans.org
|
||||
ca@crans.org ca@lists.crans.org
|
||||
cri@crans.org cri@lists.crans.org
|
||||
mumudvb-dev@crans.org mumudvb-dev@lists.crans.org
|
||||
crans_dvbstream-dev@crans.org crans_dvbstream-dev@lists.crans.org
|
||||
impression@crans.org impression@lists.crans.org
|
||||
ads@crans.org ads@lists.crans.org
|
||||
bds@crans.org bds@lists.crans.org
|
||||
laos@crans.org laos@lists.crans.org
|
||||
sono@crans.org sono@lists.crans.org
|
||||
senegal@crans.org senegal@lists.crans.org
|
||||
club-info@crans.org club-info@lists.crans.org
|
||||
cresid@crans.org cresid@lists.crans.org
|
||||
guinee@crans.org guinee@lists.crans.org
|
||||
ensanime@crans.org ensanime@lists.crans.org
|
||||
ptit-dej.bde@crans.org ptit-dej.bde@lists.crans.org
|
||||
aspique@crans.org aspique@lists.crans.org
|
||||
kfet.bde@crans.org kfet.bde@lists.crans.org
|
||||
club-krobot@crans.org club-krobot@lists.crans.org
|
||||
club-escalade@crans.org club-escalade@lists.crans.org
|
||||
club-4ltrophy@crans.org club-4ltrophy@lists.crans.org
|
||||
club-meca@crans.org club-meca@lists.crans.org
|
||||
all.bde@crans.org all.bde@lists.crans.org
|
||||
crepas@crans.org crepas@lists.crans.org
|
||||
cog@crans.org cog@lists.crans.org
|
||||
cine-club@crans.org cine-club@lists.crans.org
|
||||
club-musique@crans.org club-musique@lists.crans.org
|
||||
club-voile@crans.org club-voile@lists.crans.org
|
||||
natation@crans.org natation@lists.crans.org
|
||||
med@crans.org med@lists.crans.org
|
||||
com-ens@crans.org com-ens@lists.crans.org
|
||||
all.bda@crans.org all.bda@lists.crans.org
|
||||
clash@crans.org clash@lists.crans.org
|
||||
groupef@crans.org groupef@lists.crans.org
|
||||
club.astro@crans.org club.astro@lists.crans.org
|
||||
soutien_scolaire@crans.org soutien_scolaire@lists.crans.org
|
||||
impro@crans.org impro@lists.crans.org
|
||||
coopeea@crans.org coopeea@lists.crans.org
|
||||
club-jeu-de-role@crans.org club-jeu-de-role@lists.crans.org
|
||||
ens-agregb3@crans.org ens-agregb3@lists.crans.org
|
||||
ens-agregb1@crans.org ens-agregb1@lists.crans.org
|
||||
ens-maths2003@crans.org ens-maths2003@lists.crans.org
|
||||
install-party@crans.org install-party@lists.crans.org
|
||||
ens-b123@crans.org ens-b123@lists.crans.org
|
||||
ens-2b1@crans.org ens-2b1@lists.crans.org
|
||||
ens-2b3@crans.org ens-2b3@lists.crans.org
|
||||
ens-2b3-bavardages@crans.org ens-2b3-bavardages@lists.crans.org
|
||||
rugby-f@crans.org rugby-f@lists.crans.org
|
||||
ens-chimie@crans.org ens-chimie@lists.crans.org
|
||||
club-kitchens@crans.org club-kitchens@lists.crans.org
|
||||
club-piano@crans.org club-piano@lists.crans.org
|
||||
club-savoie@crans.org club-savoie@lists.crans.org
|
||||
reservations@crans.org reservations@lists.crans.org
|
||||
bde2004@crans.org bde2004@lists.crans.org
|
||||
bde2005@crans.org bde2005@lists.crans.org
|
||||
wei.bde@crans.org wei.bde@lists.crans.org
|
||||
routard.bde@crans.org routard.bde@lists.crans.org
|
||||
membres-bds@crans.org membres-bds@lists.crans.org
|
||||
lessensdelart@crans.org lessensdelart@lists.crans.org
|
||||
clubs.bde@crans.org clubs.bde@lists.crans.org
|
||||
club.aviron@crans.org club.aviron@lists.crans.org
|
||||
elus_ens@crans.org elus_ens@lists.crans.org
|
||||
club-bridge-echecs@crans.org club-bridge-echecs@lists.crans.org
|
||||
club-volley-f@crans.org club-volley-f@lists.crans.org
|
||||
club-chorale@crans.org club-chorale@lists.crans.org
|
||||
club-interens@crans.org club-interens@lists.crans.org
|
||||
club-salsa@crans.org club-salsa@lists.crans.org
|
||||
bureau.bde@crans.org bureau.bde@lists.crans.org
|
||||
concerts.bda@crans.org concerts.bda@lists.crans.org
|
||||
club-comedie-musicale@crans.org club-comedie-musicale@lists.crans.org
|
||||
mailman@crans.org mailman@lists.crans.org
|
||||
|
||||
# +---------------------------------------------------------------------------------+
|
||||
# | Compatibilite anciennes ML(@crans.ens-cachan.fr) -> nouvelles(@lists.crans.org) |
|
||||
# +---------------------------------------------------------------------------------+
|
||||
|
||||
bureau@crans.ens-cachan.fr bureau@lists.crans.org
|
||||
nounou@crans.ens-cachan.fr nounou@lists.crans.org
|
||||
roots@crans.ens-cachan.fr roots@lists.crans.org
|
||||
respbats@crans.ens-cachan.fr respbats@lists.crans.org
|
||||
moderateurs@crans.ens-cachan.fr moderateurs@lists.crans.org
|
||||
disconnect@crans.ens-cachan.fr disconnect@lists.crans.org
|
||||
ca@crans.ens-cachan.fr ca@lists.crans.org
|
||||
cri@crans.ens-cachan.fr cri@lists.crans.org
|
||||
mumudvb-dev@crans.ens-cachan.fr mumudvb-dev@lists.crans.org
|
||||
crans_dvbstream-dev@crans.ens-cachan.fr crans_dvbstream-dev@lists.crans.org
|
||||
impression@crans.ens-cachan.fr impression@lists.crans.org
|
||||
ads@crans.ens-cachan.fr ads@lists.crans.org
|
||||
bds@crans.ens-cachan.fr bds@lists.crans.org
|
||||
laos@crans.ens-cachan.fr laos@lists.crans.org
|
||||
sono@crans.ens-cachan.fr sono@lists.crans.org
|
||||
senegal@crans.ens-cachan.fr senegal@lists.crans.org
|
||||
club-info@crans.ens-cachan.fr club-info@lists.crans.org
|
||||
cresid@crans.ens-cachan.fr cresid@lists.crans.org
|
||||
guinee@crans.ens-cachan.fr guinee@lists.crans.org
|
||||
ensanime@crans.ens-cachan.fr ensanime@lists.crans.org
|
||||
ptit-dej.bde@crans.ens-cachan.fr ptit-dej.bde@lists.crans.org
|
||||
aspique@crans.ens-cachan.fr aspique@lists.crans.org
|
||||
kfet.bde@crans.ens-cachan.fr kfet.bde@lists.crans.org
|
||||
club-krobot@crans.ens-cachan.fr club-krobot@lists.crans.org
|
||||
club-escalade@crans.ens-cachan.fr club-escalade@lists.crans.org
|
||||
club-4ltrophy@crans.ens-cachan.fr club-4ltrophy@lists.crans.org
|
||||
club-meca@crans.ens-cachan.fr club-meca@lists.crans.org
|
||||
all.bde@crans.ens-cachan.fr all.bde@lists.crans.org
|
||||
crepas@crans.ens-cachan.fr crepas@lists.crans.org
|
||||
cog@crans.ens-cachan.fr cog@lists.crans.org
|
||||
cineclub@crans.ens-cachan.fr cineclub@lists.crans.org
|
||||
cine.club@crans.ens-cachan.fr cine.club@lists.crans.org
|
||||
cine-club@crans.ens-cachan.fr cine-club@lists.crans.org
|
||||
club-musique@crans.ens-cachan.fr club-musique@lists.crans.org
|
||||
club-voile@crans.ens-cachan.fr club-voile@lists.crans.org
|
||||
natation@crans.ens-cachan.fr natation@lists.crans.org
|
||||
med@crans.ens-cachan.fr med@lists.crans.org
|
||||
com-ens@crans.ens-cachan.fr com-ens@lists.crans.org
|
||||
all.bda@crans.ens-cachan.fr all.bda@lists.crans.org
|
||||
clash@crans.ens-cachan.fr clash@lists.crans.org
|
||||
groupef@crans.ens-cachan.fr groupef@lists.crans.org
|
||||
club.astro@crans.ens-cachan.fr club.astro@lists.crans.org
|
||||
soutien_scolaire@crans.ens-cachan.fr soutien_scolaire@lists.crans.org
|
||||
impro@crans.ens-cachan.fr impro@lists.crans.org
|
||||
coopeea@crans.ens-cachan.fr coopeea@lists.crans.org
|
||||
club-jeu-de-role@crans.ens-cachan.fr club-jeu-de-role@lists.crans.org
|
||||
ens-agregb3@crans.ens-cachan.fr ens-agregb3@lists.crans.org
|
||||
ens-agregb1@crans.ens-cachan.fr ens-agregb1@lists.crans.org
|
||||
ens-maths2003@crans.ens-cachan.fr ens-maths2003@lists.crans.org
|
||||
install-party@crans.ens-cachan.fr install-party@lists.crans.org
|
||||
ens-b123@crans.ens-cachan.fr ens-b123@lists.crans.org
|
||||
ens-2b1@crans.ens-cachan.fr ens-2b1@lists.crans.org
|
||||
ens-2b3@crans.ens-cachan.fr ens-2b3@lists.crans.org
|
||||
ens-2b3-bavardages@crans.ens-cachan.fr ens-2b3-bavardages@lists.crans.org
|
||||
rugby-f@crans.ens-cachan.fr rugby-f@lists.crans.org
|
||||
ens-chimie@crans.ens-cachan.fr ens-chimie@lists.crans.org
|
||||
club-kitchens@crans.ens-cachan.fr club-kitchens@lists.crans.org
|
||||
club-piano@crans.ens-cachan.fr club-piano@lists.crans.org
|
||||
club-savoie@crans.ens-cachan.fr club-savoie@lists.crans.org
|
||||
reservations@crans.ens-cachan.fr reservations@lists.crans.org
|
||||
bde2004@crans.ens-cachan.fr bde2004@lists.crans.org
|
||||
bde2005@crans.ens-cachan.fr bde2005@lists.crans.org
|
||||
wei.bde@crans.ens-cachan.fr wei.bde@lists.crans.org
|
||||
routard.bde@crans.ens-cachan.fr routard.bde@lists.crans.org
|
||||
membres-bds@crans.ens-cachan.fr membres-bds@lists.crans.org
|
||||
lessensdelart@crans.ens-cachan.fr lessensdelart@lists.crans.org
|
||||
clubs.bde@crans.ens-cachan.fr clubs.bde@lists.crans.org
|
||||
club.aviron@crans.ens-cachan.fr club.aviron@lists.crans.org
|
||||
elus_ens@crans.ens-cachan.fr elus_ens@lists.crans.org
|
||||
club-bridge-echecs@crans.ens-cachan.fr club-bridge-echecs@lists.crans.org
|
||||
club-volley-f@crans.ens-cachan.fr club-volley-f@lists.crans.org
|
||||
club-chorale@crans.ens-cachan.fr club-chorale@lists.crans.org
|
||||
club-interens@crans.ens-cachan.fr club-interens@lists.crans.org
|
||||
club-salsa@crans.ens-cachan.fr club-salsa@lists.crans.org
|
||||
bureau.bde@crans.ens-cachan.fr bureau.bde@lists.crans.org
|
||||
concerts.bda@crans.ens-cachan.fr concerts.bda@lists.crans.org
|
||||
club-comedie-musicale@crans.ens-cachan.fr club-comedie-musicale@lists.crans.org
|
||||
mailman@crans.ens-cachan.fr mailman@lists.crans.org
|
Loading…
Reference in a new issue