#!/usr/bin/env bash # Print Certbot dns-cloudns "Credentials File Content" from project .env. # Run from repo root (or any dir with .env). Output is for pasting into # NPMplus: Add TLS Certificate → DNS Challenge → ClouDNS → "Credentials File Content *". # Usage: ./scripts/certbot/print-cloudns-credentials-from-env.sh set -e REPO_ROOT="${REPO_ROOT:-$(cd -P "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" ENV_FILE="${ENV_FILE:-$REPO_ROOT/.env}" if [ ! -f "$ENV_FILE" ]; then echo "Error: .env not found at $ENV_FILE" >&2 echo "Create it from .env.example and set CLOUDNS_AUTH_ID and CLOUDNS_AUTH_PASSWORD." >&2 exit 1 fi set +u # shellcheck source=/dev/null source "$ENV_FILE" set -u if [ -z "${CLOUDNS_AUTH_ID:-}" ] || [ -z "${CLOUDNS_AUTH_PASSWORD:-}" ]; then echo "Error: Set CLOUDNS_AUTH_ID and CLOUDNS_AUTH_PASSWORD in .env" >&2 echo "See: .env.example (ClouDNS section), https://www.cloudns.net/api-settings/" >&2 echo "" >&2 echo "If you prefer Cloudflare DNS challenge instead, use DNS Challenge → Cloudflare" >&2 echo "and run: ./scripts/certbot/print-cloudflare-credentials-from-env.sh" >&2 exit 1 fi # Use 'key = value' format (spaces) so NPM/Certbot parser reliably finds both properties echo "dns_cloudns_auth_id = $CLOUDNS_AUTH_ID" echo "dns_cloudns_auth_password = $CLOUDNS_AUTH_PASSWORD" if [ -n "${CLOUDNS_SUB_AUTH_ID:-}" ]; then echo "dns_cloudns_sub_auth_id = $CLOUDNS_SUB_AUTH_ID" elif [ -n "${CLOUDNS_SUB_AUTH_USER:-}" ]; then echo "dns_cloudns_sub_auth_user = $CLOUDNS_SUB_AUTH_USER" fi