Update scripts/setup-template.py
parent
c5e32f8af4
commit
c04297a3be
|
@ -1,13 +1,36 @@
|
|||
#IMPORT
|
||||
import os
|
||||
import argparse
|
||||
import warnings
|
||||
|
||||
|
||||
#CACHE_FUNCTIONS
|
||||
def get_cached_email() -> str:
|
||||
with open("../email.cache", "r") as f:
|
||||
email = f.read().strip()
|
||||
return email
|
||||
|
||||
|
||||
def cache_email(email: str) -> None:
|
||||
try:
|
||||
with open("../email.cache", "w") as f:
|
||||
f.write(email)
|
||||
except Exception as e:
|
||||
warnings.warn(e, Warning)
|
||||
|
||||
#PARSE_ARGS
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("domain")
|
||||
parser.add_argument("email")
|
||||
parser.add_argument("email", default=None) # to not recache emails retreived from cache
|
||||
parser.add_argument("cache_email", default=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
#CACHE
|
||||
if args.cache_email is True and args.email is not None:
|
||||
cache_email(email)
|
||||
if args.email is None:
|
||||
args.email = get_cached_email()
|
||||
|
||||
#QUICK_RECOVER
|
||||
os.makedirs(os.path.dirname("/opt/quick-recover/"), exist_ok=True)
|
||||
with open("/opt/quick-recover/#service.conf", "w") as f:
|
||||
|
|
Loading…
Reference in New Issue