Replace sys.args with argparse

pull/4/head
drunkendog 2023-08-14 22:49:43 +01:00
parent bafd045a5f
commit 33dd18c792
1 changed files with 10 additions and 3 deletions

View File

@ -1,9 +1,16 @@
#IMPORT
import os, sys
import os
import argparse
#PARSE_ARGS
parser = argparse.ArgumentParser()
parser.add_argument("domain")
parser.add_argument("email")
args = parser.parse_args()
#FILE_READ
with open("../nginx-site-template.conf", "r") as f:
template = f.read().replace("#serverNameVar", f"{sys.argv[1]}").replace("#http://127.0.0.1:8080/", f"#ip_address")
template = f.read().replace("#serverNameVar", f"{args.domain}").replace("#http://127.0.0.1:8080/", f"#ip_address")
#ADDITIONAL_REPLACE
#FILE_WRITE
@ -11,7 +18,7 @@ with open("/etc/nginx/sites-available/#service.conf", "w") as f:
f.write(template)
#GET_CERT
os.system(f"sh ../getcert.sh {sys.argv[1]} {sys.argv[2]}")
os.system(f"sh ../getcert.sh {args.domain} {args.email}")
#GENERATE_NGINX
# depreceated, TODO: replace with os.subprocess