Docker-Davinci-Resolve-Proj.../pgadmin-config-creator/app.py

33 lines
1.0 KiB
Python
Raw Normal View History

2022-07-30 03:13:47 +00:00
import json
import os
2022-07-30 04:31:17 +00:00
import time
2022-07-30 03:13:47 +00:00
# quit if config file already exists
if os.path.exists("/config/servers.json"):
2022-07-31 20:03:12 +00:00
print("/config/servers.json already exists.")
else:
# open json file in docker volume
with open("/config/servers.json", "w") as f:
print("created " + f.name)
# template json string
template_string = (
'{"Servers": {"1": {"Name": "DavinciResolve", '
'"Group": "Servers", "Port": 5432, "Username": '
'"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}'
)
data = json.loads(template_string)
# fix username
data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER")
print("Printing json to file...")
print(data)
# update config file
json.dump(data, f, indent=2)
2022-07-31 20:03:12 +00:00
print("Done. Sleeping...")
2022-07-30 12:48:07 +00:00
# Sleep until GHA Healthchecks are complete.
# I'm sure there's a better way to get this to not
# stall a docker-compose up --wait, but I don't know
# what it is
2022-07-30 05:00:03 +00:00
time.sleep(125)