Commit 3293f7fb authored by Robin Fischer's avatar Robin Fischer

Add python script to start cert renew

parent 2e852c23
#!/usr/bin/python3
import os
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("workingDir")
parser.add_argument("targetSiteDirectory", help="")
parser.add_argument("templateFile", help="")
parser.add_argument("contactEmail")
parser.add_argument("gitlabProjectId")
parser.add_argument("--domain", action="append")
args = parser.parse_args()
current_dir = os.getcwd()
working_dir = os.path.join(current_dir, args.workingDir)
script_dir = os.path.dirname(os.path.realpath(__file__))
auth_script_path = os.path.join(script_dir, "authenticator.py")
template_path = os.path.join(current_dir, args.templateFile)
target_site_dir = os.path.join(current_dir, args.targetSiteDirectory)
certbot_config_dir = os.path.join(working_dir, "config")
certbot_parameters = [
"certbot", "certonly",
"--email", args.contactEmail,
"--manual",
"--manual-auth_hook", "\"" + auth_script_path + " " + template_path + " " + target_site_dir + "\"",
"--config-dir", certbot_config_dir,
"--logs-dir", os.path.join(working_dir, "logs"),
"--work-dir", os.path.join(working_dir, "workspace"),
"--manual-public-ip-logging-ok",
"--agree-tos"
]
for domain in args.domain:
certbot_parameters.extend(["-d", domain])
print("parameters: " + str(certbot_parameters))
#subprocess.run(certbot_parameters, capture_output=True)
upload_script_path = os.path.join(script_dir, "uploadCert.py")
for domain in args.domain:
upload_parameters = [
"python3", upload_script_path,
domain,
args.gitlabProjectId,
os.path.join(certbot_config_dir, "live/" + domain + "/fullchain.pem"),
os.path.join(certbot_config_dir, "live/" + domain + "/privatekey.pem"),
]
print("upload paramters: " + str(upload_parameters))
#subprocess.run(upload_script_path, capture_output=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment