2026-02-17 16:12:46 +13:00
|
|
|
#!/bin/bash
|
2026-02-19 12:07:37 +13:00
|
|
|
set -e
|
2026-02-17 16:12:46 +13:00
|
|
|
|
2026-02-19 12:07:37 +13:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Detect whether any bind backend is configured and enabled.
|
|
|
|
|
# Uses the same config search order as the application itself.
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
BIND_ENABLED=$(python3 - <<'EOF'
|
|
|
|
|
import yaml, sys, os
|
2026-02-17 16:12:46 +13:00
|
|
|
|
2026-02-19 12:07:37 +13:00
|
|
|
config_paths = [
|
|
|
|
|
"/etc/directdnsonly/app.yml",
|
|
|
|
|
"/etc/directdnsonly/app.yaml",
|
|
|
|
|
"/app/app.yml",
|
|
|
|
|
"/app/app.yaml",
|
|
|
|
|
"/app/config/app.yml",
|
|
|
|
|
"/app/config/app.yaml",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
config = {}
|
|
|
|
|
for path in config_paths:
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
with open(path) as f:
|
|
|
|
|
config = yaml.safe_load(f) or {}
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
backends = config.get("dns", {}).get("backends", {})
|
|
|
|
|
for cfg in backends.values():
|
|
|
|
|
if isinstance(cfg, dict) and cfg.get("type") == "bind" and cfg.get("enabled", False):
|
|
|
|
|
print("true")
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
print("false")
|
|
|
|
|
EOF
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if [ "$BIND_ENABLED" = "true" ]; then
|
|
|
|
|
echo "[entrypoint] BIND backend enabled — starting named"
|
|
|
|
|
/usr/sbin/named -u bind -f &
|
|
|
|
|
else
|
|
|
|
|
echo "[entrypoint] No BIND backend configured — skipping named"
|
|
|
|
|
fi
|
2026-02-17 16:12:46 +13:00
|
|
|
|
|
|
|
|
# Start the application
|
2026-02-19 12:07:37 +13:00
|
|
|
exec python -m directdnsonly
|