from pastafariutils import linux import distro import argparse from pathlib import Path import os, sys parser=argparse.ArgumentParser(prog='manage_apache.py', description='A tool for admin an apache server') parser.add_argument("--set_reload_apache", action='store_true') args=parser.parse_args() tmp_file='/tmp/reload_apache_file' if args.set_reload_apache: Path(tmp_file).touch() else: if os.path.isfile(tmp_file): print('Reloading apache because is neccesary for mod_md from apache...') linux_service={'debian' : 'apache2', 'ubuntu' : 'apache2', 'fedora' : 'httpd', 'almalinux' : 'httpd', 'rocky' : 'httpd', 'arch' : 'httpd', 'gentoo': 'apache2'} if linux.systemd_service('reload', linux_service): os.unlink(tmp_file) else: print('Error: cannot reload apache for update mod_md certificates') sys.exit(1)