diff --git a/files/cert2json.py b/files/cert2json.py
index b94e01fd0a2eb51a8f63ab93a080ca971a19ff67..e79bce6d65353501efc83034510974c076745a74 100755
--- a/files/cert2json.py
+++ b/files/cert2json.py
@@ -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)