--Addded version manager
	--Parser
This commit is contained in:
George 2026-06-19 16:37:34 +05:30
commit 8090c2e5ea
2 changed files with 86 additions and 0 deletions

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
venv/
# Docker compose file
compose_changes.json
docker-compose.yml
# Python cache
__pycache__/
*.pyc
# IDE files
.vscode/
.idea/

71
dockerConfig.py Normal file
View File

@ -0,0 +1,71 @@
import re
import json
import os
from datetime import datetime
COMPOSE_FILE = "docker-compose.yml"
JSON_FILE = "compose_changes.json"
def read_json():
if not os.path.exists(JSON_FILE):
return {"file": "docker-compose.yml", "version": 0}
with open(JSON_FILE) as f:
return json.load(f)
def write_json(changes):
data = read_json()
data["version"] += 1
data["last_updated"] = datetime.now().isoformat()
with open(JSON_FILE, "w") as f:
json.dump(data, f, indent=2)
return data["version"]
def update_compose(
icesecretwrite=None,
icesecretread=None,
dbDriver=None,
dbHost=None,
dbPort=None,
database=None,
dbUsername=None,
dbPassword=None
):
with open(COMPOSE_FILE, "r") as f:
content = f.read()
changes = {
"MUMBLE_CONFIG_icesecretwrite": icesecretwrite,
"MUMBLE_CONFIG_icesecretread": icesecretread,
"MUMBLE_CONFIG_dbDriver": dbDriver,
"MUMBLE_CONFIG_dbHost": dbHost,
"MUMBLE_CONFIG_dbPort": dbPort,
"MUMBLE_CONFIG_database": database,
"MUMBLE_CONFIG_dbUsername": dbUsername,
"MUMBLE_CONFIG_dbPassword": dbPassword,
}
for key, value in changes.items():
if value is None:
continue # skip fields not passed in
# replace the value after the = sign
content = re.sub(
rf"({key}=).*",
rf"\g<1>{value}",
content
)
with open(COMPOSE_FILE, "w") as f:
f.write(content)
version = write_json(changes)
print(f"[✓] docker-compose.yml updated")
# --- usage ---
update_compose(
dbHost="172.test.test.test",
dbPassword="testpassword",
dbPort="5437test"
)