#!/usr/bin/env bash set -Eeuo pipefail target_path="${1:-compose/.env}" force_write="${FORCE_WRITE:-0}" if [[ -e "$target_path" && "$force_write" != "1" ]]; then printf 'Refusing to overwrite %s; set FORCE_WRITE=1 to replace it.\n' "$target_path" >&2 exit 1 fi if ! command -v openssl >/dev/null 2>&1; then printf 'openssl is required to generate local secrets.\n' >&2 exit 1 fi target_directory="$(dirname -- "$target_path")" mkdir -p -- "$target_directory" umask 077 random_secret() { openssl rand -hex 32 } cat > "$target_path" <