1. try #1

Merged
pi-farm merged 47 commits from dev into main 2026-10-28 20:53:38 +00:00
Showing only changes of commit 3f7872d23d - Show all commits
+9 -26
View File
@@ -331,42 +331,25 @@ jobs:
cat << 'EOF' > update_script.py cat << 'EOF' > update_script.py
import os, re import os, re
# 1. Wir lesen die Schlüsselnamen (Keys) aus der buildargs.env aus, env_keys = [
# damit wir wissen, welche Variablen als Platzhalter eingefügt werden sollen. "SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME",
env_keys = [] "SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK",
if os.path.exists("buildargs.env"): "DNS_FORWARDER", "SAMBA_ADMIN_PASSWORD"
with open("buildargs.env", "r", encoding="utf-8") as f: ]
for line in f:
line = line.strip()
# Ignoriere Kommentare und leere Zeilen
if line and not line.startswith("#") and "=" in line:
key = line.split("=")[0].strip()
# Wir wollen nur die SAMBA_-Variablen oder alle BUILD_-Variablen ausschließen
if key.startswith("SAMBA_") or key.startswith("DNS_"):
env_keys.append(key)
# Falls keine spezifischen gefunden wurden, Fallback auf die üblichen # Env-Block ohne F-String-Klammern zusammenbauen, damit Gitea nicht stolpert
if not env_keys:
env_keys = [
"SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME",
"SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK",
"DNS_FORWARDER", "SAMBA_ADMIN_PASSWORD"
]
# 2. Erzeuge den Env-Block mit ${VARIABLE_NAME} Syntax (doppelte geschweifte Klammern für F-String Maskierung)
env_block_lines = [] env_block_lines = []
for key in env_keys: for key in env_keys:
env_block_lines.append(f" {key}: ${{{key}}}") line = " " + key + ": ${" + key + "}"
env_block_lines.append(line)
env_block_str = "\n".join(env_block_lines) env_block_str = "\n".join(env_block_lines)
# 3. Template einlesen und Platzhalter ersetzen
template_name = ".gitea/docker-compose.template" if os.path.exists(".gitea/docker-compose.template") else "docker-compose.template" template_name = ".gitea/docker-compose.template" if os.path.exists(".gitea/docker-compose.template") else "docker-compose.template"
with open(template_name, "r", encoding="utf-8") as f: with open(template_name, "r", encoding="utf-8") as f:
content = f.read() content = f.read()
# Ersetzungen durchführen
content = content.replace("__REPO_NAME__", "samba-ad-dc") content = content.replace("__REPO_NAME__", "samba-ad-dc")
content = content.replace("__FULL_URL__", "git.pi-farm.de/pi-farm/samba-ad-dc") content = content.replace("__FULL_URL__", "git.pi-farm.de/pi-farm/samba-ad-dc")
content = content.replace("__BUILD_TAG__", os.environ.get("FINAL_TAG", "trixie")) content = content.replace("__BUILD_TAG__", os.environ.get("FINAL_TAG", "trixie"))
@@ -374,7 +357,7 @@ jobs:
with open("docker-compose.yml", "w", encoding="utf-8") as f: with open("docker-compose.yml", "w", encoding="utf-8") as f:
f.write(content) f.write(content)
print("docker-compose.yml erfolgreich mit Platzhaltern generiert!") print("docker-compose.yml erfolgreich generiert!")
EOF EOF
python3 update_script.py python3 update_script.py
rm -f update_script.py rm -f update_script.py