From b684ad330aeec7e32678789eeae5fea51a09dd4f Mon Sep 17 00:00:00 2001 From: jigen Date: Tue, 25 Feb 2020 18:30:20 +0100 Subject: [PATCH] Fixed )( and if/else --- OTcerts.py | 55 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/OTcerts.py b/OTcerts.py index 1d03115..af789ab 100644 --- a/OTcerts.py +++ b/OTcerts.py @@ -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)