-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobject-store.sh
More file actions
94 lines (80 loc) · 2.54 KB
/
Copy pathobject-store.sh
File metadata and controls
94 lines (80 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This Bash/ZSH script simplify running tests that use Azurite and/or MinIO.
# It purposely does not have a #! as it is written to work with Bash and ZSH.
set -e
# Variables.
AZURITE_FOLDER=
AZURITE_PID=
MINIO_FOLDER=
MINIO_PID=
# Functions.
# Azurite Blob: http://127.0.0.1:10000.
# Azurite Queue: http://127.0.0.1:10001.
# Azurite Table: http://127.0.0.1:10002.
start_azurite() {
print_arrow_message "Start Azurite"
AZURITE_FOLDER=$(mktemp -d)
azurite -l "$AZURITE_FOLDER" --silent --skipApiVersionCheck &
AZURITE_PID=$!
sleep 1 # Simple way to ensure Azurite has time to start.
az storage container create -n modelardb --connection-string 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;'
echo
}
stop_azurite() {
print_arrow_message "Stop Azurite"
if [ ! -z "$AZURITE_FOLDER" ]
then
kill "$AZURITE_PID"
sleep 1 # Simple way to ensure Azurite has time to write.
rm -rf "$AZURITE_FOLDER"
fi
echo
}
# MinIO API: http://127.0.0.1:9000.
# MinIO WebUI: http://127.0.0.1:{random}.
start_minio() {
print_arrow_message "Start MinIO"
MINIO_FOLDER=$(mktemp -d)
minio server "$MINIO_FOLDER" &
MINIO_PID=$!
sleep 1 # Simple way to ensure MinIO has time to start.
mcli alias set local http://127.0.0.1:9000 minioadmin minioadmin
mcli mb local/modelardb
echo
}
stop_minio() {
print_arrow_message "Stop MinIO"
if [ ! -z "$MINIO_FOLDER" ]
then
kill "$MINIO_PID"
sleep 1 # Simple way to ensure MinIO has time to write.
rm -rf "$MINIO_FOLDER"
fi
echo
}
print_error_message() {
printf "\033[1;31mERROR: \033[39m%s\n" "$1"
}
print_arrow_message() {
printf "\033[1;92m==> \033[39m%s \033[m\n" "$1"
}
check_for_dependencies() {
if [[ -n $ZSH_VERSION ]]; then
if builtin whence -p azurite az minio mcli &> /dev/null; then
return # Returns as all dependencies are installed and the shell is ZSH.
fi
elif [[ -n $BASH_VERSION ]]; then
if builtin type -P azurite az minio mcli &> /dev/null; then
return # Returns as all dependencies are installed and the shell is Bash.
fi
fi
print_error_message "requires Bash or ZSH and azurite, az, minio, and mcli"
return 1
}
# Main.
check_for_dependencies
trap 'stop_azurite; stop_minio' EXIT
start_azurite
start_minio
print_arrow_message "Waiting"
echo "Started object stores, press enter to stop."
read