Files
2026-07-19 15:07:30 +02:00

33 lines
808 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SERVICES_DIR="${ROOT_DIR}/infrastructure/services"
FORCE=0
if [[ "${1:-}" == "-y" || "${1:-}" == "--force" ]]; then
FORCE=1
fi
mapfile -d '' -t targets < <(find "${SERVICES_DIR}" -type f -name '*.env' -print0 | sort -z)
if [[ "${#targets[@]}" -eq 0 ]]; then
echo "No .env file found, nothing to do."
exit 0
fi
echo "This will permanently delete ${#targets[@]} .env file(s) (secrets/passwords included):"
printf ' %s\n' "${targets[@]/#${ROOT_DIR}\//}"
if [[ "${FORCE}" -ne 1 ]]; then
read -r -p "Continue? [y/N] " reply
if [[ ! "${reply}" =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
fi
rm -f -- "${targets[@]}"
echo "Deleted ${#targets[@]} .env file(s). Run 'make init' to regenerate them."