Skip to content
Snippets Groups Projects
Unverified Commit 1a14bf58 authored by Max Adamo's avatar Max Adamo
Browse files

code refactoring

parent fe559b96
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ import yaml
from docopt import docopt
BASE_DIR = '/var/www/acme_web'
ARGS = docopt(__doc__)
PROVIDER = ARGS['--provider']
if PROVIDER not in ["letsencrypt", "sectigo_ov", "sectigo_ev", "all"]:
......@@ -37,8 +38,8 @@ for acme_provider in PROVIDERS:
cbot_out, _ = cbot_child.communicate()
devoded_output = cbot_out.decode("utf-8").split("\n")
yaml_file = "/var/www/acme_web/{}.yaml".format(acme_provider)
json_file = "/var/www/acme_web/{}.json".format(acme_provider)
yaml_file = "{}/{}.yaml".format(BASE_DIR, acme_provider)
json_file = "{}/{}.json".format(BASE_DIR, acme_provider)
# open yaml for writing
with open(yaml_file, "w") as yaml_out:
......@@ -69,10 +70,13 @@ for acme_provider in PROVIDERS:
# fix permissions
os.chmod('/var/www/acme_web', 0o755)
for www_file in glob('/var/www/acme_web/*'):
os.chmod(BASE_DIR, 0o755)
for www_file in glob('{}/*'.format(BASE_DIR)):
os.chmod(www_file, 0o644)
# write timestamp
TIMENOW = time.strftime('%Y-%m-%d %X %Z')
TIMESTAMP_JS = """var mytimestamp = "This report was generated on {}"
document.getElementById("factstimestamp").innerHTML = mytimestamp;\n""".format(TIMENOW)
with open('{}/timestamp.js'.format(BASE_DIR), 'w') as timstamp_file:
timstamp_file.write(TIMESTAMP_JS)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment