2022-09-23 21:41:25 +01:00
|
|
|
#IMPORT
|
2023-08-14 22:49:43 +01:00
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
#PARSE_ARGS
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("domain")
|
|
|
|
parser.add_argument("email")
|
|
|
|
args = parser.parse_args()
|
2022-09-23 21:41:25 +01:00
|
|
|
|
2023-08-14 23:13:31 +01:00
|
|
|
#QUICK_RECOVER
|
|
|
|
os.makedirs(os.path.dirname("/opt/quick-recover/"), exist_ok=True)
|
|
|
|
with open("/opt/quick-recover/#service.conf", "w") as f:
|
2023-08-23 19:36:00 +01:00
|
|
|
f.write(f"export DOMAIN='{args.domain}'\n")
|
|
|
|
f.write(f"export EMAIL='{args.email}'\n")
|
2023-08-14 23:13:31 +01:00
|
|
|
|
2022-09-23 21:41:25 +01:00
|
|
|
#FILE_READ
|
|
|
|
with open("../nginx-site-template.conf", "r") as f:
|
2023-08-14 22:49:43 +01:00
|
|
|
template = f.read().replace("#serverNameVar", f"{args.domain}").replace("#http://127.0.0.1:8080/", f"#ip_address")
|
2022-09-23 21:58:47 +01:00
|
|
|
#ADDITIONAL_REPLACE
|
2022-09-23 21:41:25 +01:00
|
|
|
|
|
|
|
#FILE_WRITE
|
|
|
|
with open("/etc/nginx/sites-available/#service.conf", "w") as f:
|
|
|
|
f.write(template)
|
|
|
|
|
2022-09-26 14:26:55 +01:00
|
|
|
#GET_CERT
|
2023-08-14 22:49:43 +01:00
|
|
|
os.system(f"sh ../getcert.sh {args.domain} {args.email}")
|
2022-09-26 14:26:55 +01:00
|
|
|
|
2022-09-23 21:41:25 +01:00
|
|
|
#GENERATE_NGINX
|
|
|
|
# depreceated, TODO: replace with os.subprocess
|
|
|
|
os.system("sh ../nginx-ensite.sh #service")
|
|
|
|
|
|
|
|
#START_CONTAINER
|
2022-09-29 20:01:59 +01:00
|
|
|
os.system("sh launch-docker.sh")
|
|
|
|
|
|
|
|
#POST_LAUNCH_COMMANDS
|