Files
azure-storage-emulator/add-account.sh
Slawomir Koszewski 01b81e41a8 Enhance emulator setup with Caddy support and update documentation
- Added Caddyfile example for HTTPS configuration.
- Updated README to include Caddy as an optional component.
- Modified make-certs.sh to use dynamic account names for certificate generation.
- Improved add-account.sh to handle missing accounts.env file gracefully.
- Enhanced run-server.sh to support Caddy integration and OAuth options.
2026-02-26 21:36:38 +01:00

28 lines
673 B
Bash
Executable File

#!/usr/bin/env bash
if [[ -z "$1" ]]; then
echo "Usage: $0 <account-name> [ password ]"
exit 1
fi
if [[ -z "$2" ]]; then
PASSWORD=$(openssl rand -base64 32)
else
PASSWORD=$(echo -n "$2" | base64)
fi
AZURITE_DIR="storage"
mkdir -p "$AZURITE_DIR"
AZURITE_ACCOUNTS_FILE="$AZURITE_DIR/accounts.env"
if [[ -f "$AZURITE_ACCOUNTS_FILE" ]]; then
. "$AZURITE_ACCOUNTS_FILE"
STORAGE_ACCOUNTS=($(echo "$AZURITE_ACCOUNTS" | tr ';' ' '))
else
# No accounts file, start with an empty array
STORAGE_ACCOUNTS=()
fi
STORAGE_ACCOUNTS+=("$1:$PASSWORD")
printf 'AZURITE_ACCOUNTS="%s"\n' $(IFS=';'; echo "${STORAGE_ACCOUNTS[*]}") > "$AZURITE_ACCOUNTS_FILE"