#!/usr/bin/env bash
set -euo pipefail

DOCKER_BIN="${DOCKER_BIN:-/usr/local/bin/docker}"
AUTHENTIK_CONTAINER="${AUTHENTIK_CONTAINER:-nodedc-platform-authentik-server-1}"

"${DOCKER_BIN}" exec "${AUTHENTIK_CONTAINER}" ak shell -c '
from authentik.brands.models import Brand

cleared = []
for brand in Brand.objects.all():
    if brand.branding_custom_css:
        brand.branding_custom_css = ""
        brand.save(update_fields=["branding_custom_css"])
        cleared.append(brand.domain)

print("cleared_brand_css=" + str(len(cleared)))
if cleared:
    print("domains=" + ",".join(cleared))
'
