38 lines
1.0 KiB
Python
Executable File
38 lines
1.0 KiB
Python
Executable File
#!/usr/bin/python3
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import yaml
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('site', help='free form site name, including test/prod/else hints')
|
|
args = parser.parse_args()
|
|
|
|
template = """# created by publik-emailconf
|
|
ADMINS = (('Admin EO', 'admin+{site}.{brique}@entrouvert.com'),)
|
|
SERVER_EMAIL = 'admin+{site}.{brique}@entrouvert.com'
|
|
"""
|
|
|
|
with open('/etc/publik/publik.conf') as fh:
|
|
briques = yaml.load(fh.read())['defaults']['briques']
|
|
|
|
for brique in briques:
|
|
if brique == 'authentic2-multitenant':
|
|
briquename = 'authentic'
|
|
else:
|
|
briquename = brique
|
|
|
|
if not os.path.isdir('/etc/%s' % brique):
|
|
continue
|
|
|
|
settings_d ='/etc/%s/settings.d' % brique
|
|
if not os.path.isdir(settings_d):
|
|
os.mkdir(settings_d)
|
|
|
|
with open('/etc/%s/settings.d/email.py' % brique, 'w') as fh:
|
|
fh.write(template.format(site=args.site, brique=briquename))
|
|
|
|
for brique in briques:
|
|
print('restarting %s' % brique)
|
|
subprocess.call('systemctl restart %s' % brique, shell=True)
|