-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-dev02mo01-create.sh
43 lines (34 loc) · 1.27 KB
/
main-dev02mo01-create.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
#!/bin/bash
# --------------------------------------------------------------------------------------
# access to vm
# ssh [email protected]
# ssh [email protected]
# access to mongo console
# mongo -host dev02mongo0.canadacentral.cloudapp.azure.com -port 27017 -u "root" -p "Passwordqwerty1234" -authenticationDatabase "admin"
# mongo -host dev02mongo0.canadacentral.cloudapp.azure.com -port 27017 -u "mynewdb" -p "Passwordqwerty1234" -authenticationDatabase "mynewdb"
# --------------------------------------------------------------------------------------
echo "building mongo 01 db - dev02mo01 ... "
# get credentials
cp ./credentials/azure/azure.tf ./databases/mo01/azure.tf
# prepare seed
cd ./databases/mo01/
rm ./seed.tar.gz
tar -cvzf ./seed.tar.gz ./seed
# run azure part
terraform init -input=false
terraform plan -out=tfplan -input=false
terraform apply -input=false tfplan
# test result
echo "testing mongo 01 db ... "
sleep 60
err_code="$(nc -zv dev02mongo0.canadacentral.cloudapp.azure.com 27017 2>&1 | grep Connected | wc -l)"
if [ ${err_code} -gt "0" ] ; then
echo "MONGO 01 IS UP ... "
else
echo "MONGO 01 HAS SOME PROBLEMS ... "
fi
# clean up
echo "hello world" >> ./azure.tf
rm ./azure.tf
rm ./seed.tar.gz
cd ../..