23 lines
538 B
Bash
Executable File
23 lines
538 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/azurite"
|
|
mkdir -p "$AZURITE_DIR"
|
|
|
|
AZURITE_ACCOUNTS_FILE="$AZURITE_DIR/accounts.env"
|
|
. $AZURITE_ACCOUNTS_FILE
|
|
|
|
STORAGE_ACCOUNTS=($(echo "$AZURITE_ACCOUNTS" | tr ';' ' '))
|
|
STORAGE_ACCOUNTS+=("$1:$PASSWORD")
|
|
printf 'AZURITE_ACCOUNTS="%s"\n' $(IFS=';'; echo "${STORAGE_ACCOUNTS[*]}") > "$AZURITE_ACCOUNTS_FILE"
|