bug fix abs path
This commit is contained in:
parent
8efe64530a
commit
0eb36c6301
1 changed files with 8 additions and 7 deletions
15
main.py
15
main.py
|
@ -13,9 +13,10 @@ from subprocess import call
|
|||
import os.path
|
||||
import sys
|
||||
|
||||
path =(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
config = ConfigParser()
|
||||
config.read('config.ini')
|
||||
config.read(path+'/config.ini')
|
||||
|
||||
api_hostname = config.get('Re2o', 'hostname')
|
||||
api_password = config.get('Re2o', 'password')
|
||||
|
@ -25,10 +26,6 @@ api_client = Re2oAPIClient(api_hostname, api_username, api_password)
|
|||
|
||||
client_hostname = socket.gethostname().split('.', 1)[0]
|
||||
|
||||
for arg in sys.argv:
|
||||
if arg=="--force":
|
||||
generate(api_client)
|
||||
|
||||
def generate(api_client):
|
||||
all_users = api_client.list("localemail/users")
|
||||
# Création de l'environnement Jinja
|
||||
|
@ -36,10 +33,10 @@ def generate(api_client):
|
|||
template = env.get_template('templates/list')
|
||||
aliases_rendered = template.render(data=all_users)
|
||||
|
||||
fichier = open('generated/aliases','w')
|
||||
fichier = open(path+'/generated/aliases','w')
|
||||
|
||||
if os.path.isfile('aliases_local'): # if a local aliases file exist, add it's content at the beginning
|
||||
local = open('aliases_local','r')
|
||||
local = open(path+'/aliases_local','r')
|
||||
for line in local.readlines():
|
||||
fichier.write(line)
|
||||
local.close()
|
||||
|
@ -50,6 +47,10 @@ def generate(api_client):
|
|||
call(["/usr/bin/newaliases"]) # Update the aliases config file
|
||||
call(["postfix", "reload"]) # force the reloading now
|
||||
|
||||
for arg in sys.argv:
|
||||
if arg=="--force":
|
||||
generate(api_client)
|
||||
|
||||
for service in api_client.list("services/regen/"):
|
||||
if service['hostname'] == client_hostname and \
|
||||
service['service_name'] == 'mail-server' and \
|
||||
|
|
Loading…
Reference in a new issue