forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lpu.sh
executable file
·55 lines (47 loc) · 1.09 KB
/
lpu.sh
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
#!/bin/bash
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
set -e
USER="otelu"
PASS="otelp"
MONGO_INITDB_ROOT_USERNAME="otel"
MONGO_INITDB_ROOT_PASSWORD="otel"
setup_permissions() {
mongo -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD<<EOF
use admin
db.createUser(
{
user: "${USER}",
pwd: "${PASS}",
roles: [ "clusterMonitor"]
}
);
EOF
}
echo "Configuring ${USER} permissions. . ."
end=$((SECONDS+20))
while [ $SECONDS -lt $end ]; do
if setup_permissions; then
echo "Permissions configured!"
break
fi
echo "Trying again in 5 seconds. . ."
sleep 5
done
add_collections() {
mongo -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD<<EOF
use testdb
db.createCollection("orders")
EOF
}
echo "Adding collections. . ."
end=$((SECONDS+20))
while [ $SECONDS -lt $end ]; do
if add_collections; then
echo "collections added!"
exit 0
fi
echo "Trying again in 5 seconds. . ."
sleep 5
done
echo "Failed to add collections"