Add scripts for managing Azurite storage accounts
This commit is contained in:
22
add-account.sh
Executable file
22
add-account.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user