Clean up logic

This commit is contained in:
Elliot Matson 2022-07-31 15:03:12 -05:00
parent 253da228f7
commit 921a712510

View File

@ -4,27 +4,26 @@ import time
# quit if config file already exists # quit if config file already exists
if os.path.exists("/config/servers.json"): if os.path.exists("/config/servers.json"):
print("/config/servers.json already exists. Quitting...") print("/config/servers.json already exists.")
quit() else:
# open json file in docker volume
with open("/config/servers.json", "w") as f:
# open json file in docker volume print("created " + f.name)
with open("/config/servers.json", "w") as f: # template json string
print("created " + f.name) template_string = (
# template json string '{"Servers": {"1": {"Name": "DavinciResolve", '
template_string = ( '"Group": "Servers", "Port": 5432, "Username": '
'{"Servers": {"1": {"Name": "DavinciResolve", ' '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}'
'"Group": "Servers", "Port": 5432, "Username": ' )
'"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' data = json.loads(template_string)
) # fix username
data = json.loads(template_string) data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER")
# fix username print("Printing json to file...")
data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER") print(data)
print("printing json to file...") # update config file
print(data) json.dump(data, f, indent=2)
# update config file
json.dump(data, f, indent=2)
print("Done. Sleeping...")
# Sleep until GHA Healthchecks are complete. # Sleep until GHA Healthchecks are complete.
# I'm sure there's a better way to get this to not # I'm sure there's a better way to get this to not