Fixed )( and if/else

This commit is contained in:
jigen 2020-02-25 18:30:20 +01:00
parent 5d13a5c70c
commit b684ad330a

View file

@ -346,37 +346,36 @@ if __name__ == '__main__':
logger.error('Error asking certificate for {}'.format(vhost_name))
if args.renew:
pre_hook_cmd = ""
post_hook_cmd = ""
pre_hook_cmd = None
post_hook_cmd = None
logging.info('Renewing certificates ')
if set(['webmail','hosting','liste']) & set(service_reload.keys()):
post_hook_cmd += " && systemctl reload apache2")
if set(['smtp',]) & set(service_reload.keys()):
post_hook_cmd += " && systemctl reload postfix")
if set(['mbox',]) & set(service_reload.keys()):
post_hook_cmd += " && systemctl restart dovecot")
post_hook_cmd = "systemctl reload apache2"
elif set(['smtp',]) & set(service_reload.keys()):
post_hook_cmd = "systemctl reload postfix"
elif set(['mbox',]) & set(service_reload.keys()):
post_hook_cmd = "systemctl restart dovecot"
logger.info("post_hook_cmd: {}".format(post_hook_cmd)
logger.debug("post_hook_cmd: {}".format(post_hook_cmd))
if acme_renew(config, pre_hook_cmd, post_hook_cmd, dryrun=dryrun):
logger.info("Done renew")
if set(['webmail','hosting','liste']) & set(service_reload.keys()):
# reload apache
logger.info("Restarting apache")
# ret = subprocess.run("systemctl reload apache2")
ret = os.system("systemctl reload apache2")
logger.info(ret)
if set(['smtp',]) & set(service_reload.keys()):
# reload postfix
logger.info("Restarting postfix")
# ret = subprocess.run("systemctl reload postfix")
ret = os.system("systemctl reload postfix")
logger.info(ret)
if set(['mbox',]) & set(service_reload.keys()):
# restart dovecot
logger.info("Restarting dovecot")
# ret = subprocess.run("systemctl restart dovecot")
ret = os.system("systemctl restart dovecot")
logger.info(ret)
else:
if set(['webmail','hosting','liste']) & set(service_reload.keys()):
# reload apache
logger.info("Restarting apache")
# ret = subprocess.run("systemctl reload apache2")
ret = os.system("systemctl reload apache2")
logger.info(ret)
if set(['smtp',]) & set(service_reload.keys()):
# reload postfix
logger.info("Restarting postfix")
# ret = subprocess.run("systemctl reload postfix")
ret = os.system("systemctl reload postfix")
logger.info(ret)
if set(['mbox',]) & set(service_reload.keys()):
# restart dovecot
logger.info("Restarting dovecot")
# ret = subprocess.run("systemctl restart dovecot")
ret = os.system("systemctl restart dovecot")
logger.info(ret)