Files
nixos-core/scripts/purge-dynu.sh
T
kiskaadee e832c83882 refactor(core): consolidate control plane into a single compose stack
This massive refactor transitions the project from a custom-scripted
multi-stack deployment into a unified, standard Docker Compose
architecture. This heavily simplifies GitOps workflows and native
NixOS systemd integration.

- Merge all infrastructure and portal compose files into a root docker-compose.yml
- Consolidate all service configurations and databases into a single ./config/ directory
- Remove brittle up.sh and down.sh orchestration scripts
- Fix Authelia templating by enabling X_AUTHELIA_CONFIG_FILTERS=template
- Replace all hardcoded domain names with dynamic ${DOMAIN} variables
- Archive legacy HTML documentation and architecture notes to docs/legacy/
- Introduce setup_guide.md as the single source of truth for SOPS secrets and NixOS deployment
2026-06-28 15:55:06 -05:00

50 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Path to your configuration
# Changed to project relative path
ENV_FILE="${ENV_FILE:-.env}"
# 1. Load Environment Variables
if [ -f "$ENV_FILE" ]; then
export $(grep -v '^#' "$ENV_FILE" | xargs)
else
echo "Error: .env file not found at $ENV_FILE"
exit 1
fi
# 2. Fetch Domain ID dynamically using the DOMAIN variable
echo "Fetching Domain ID for $DOMAIN..."
DOMAIN_ID=$(curl -s -X GET "https://api.dynu.com/v2/dns" \
-H "API-Key: $DYNU_API_KEY" | \
jq -r --arg DOMAIN "$DOMAIN" '.domains[] | select(.name==$DOMAIN) | .id')
if [ -z "$DOMAIN_ID" ] || [ "$DOMAIN_ID" == "null" ]; then
echo "Error: Could not find Domain ID for $DOMAIN. Check your API key and domain name."
exit 1
fi
echo "Targeting Domain ID: $DOMAIN_ID"
# 3. Identify and Delete all TXT records
echo "Searching for stale TXT records..."
TXT_RECORD_IDS=$(curl -s -X GET "https://api.dynu.com/v2/dns/$DOMAIN_ID/record" \
-H "API-Key: $DYNU_API_KEY" | \
jq -r '.dnsRecords[] | select(.recordType=="TXT") | .id')
if [ -z "$TXT_RECORD_IDS" ] || [ "$TXT_RECORD_IDS" == "null" ]; then
echo "No TXT records found. Quota should be clear."
else
for ID in $TXT_RECORD_IDS; do
echo "Deleting TXT Record ID: $ID"
curl -s -X DELETE "https://api.dynu.com/v2/dns/$DOMAIN_ID/record/$ID" \
-H "API-Key: $DYNU_API_KEY" > /dev/null
done
echo "Purge complete."
fi
# 4. Restart Traefik to trigger new challenge
echo "Restarting Traefik..."
docker compose restart traefik
echo "Process complete. Monitor logs with: docker logs traefik 2>&1 | grep -iE 'acme|dynu'"