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"
|
||||||
20
list-accounts.sh
Executable file
20
list-accounts.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
AZURITE_DIR="storage/azurite"
|
||||||
|
|
||||||
|
if [[ ! -d "$AZURITE_DIR" ]]; then
|
||||||
|
echo "No accounts found"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
AZURITE_ACCOUNTS_FILE="$AZURITE_DIR/accounts.env"
|
||||||
|
. $AZURITE_ACCOUNTS_FILE
|
||||||
|
|
||||||
|
while IFS=';' read -ra ACCOUNTS; do
|
||||||
|
for ACCOUNT in "${ACCOUNTS[@]}"; do
|
||||||
|
IFS=':' read -ra KV <<< "$ACCOUNT"
|
||||||
|
echo "Account: ${KV[0]}"
|
||||||
|
echo "Password: $(echo -n "${KV[1]}")"
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
done <<< "$AZURITE_ACCOUNTS"
|
||||||
Reference in New Issue
Block a user