forked from equinor/flotilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·104 lines (81 loc) · 3.13 KB
/
setup.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
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
95
96
97
98
99
100
101
102
103
#!/bin/bash
echo -e "-------- FLOTILLA -----------"
echo -e "Running dev setup for Flotilla...\n"
flotilla_dir=$(dirname $0)
#-------- FRONTEND -----------
echo "-------- FRONTEND -----------"
echo -e "Setting up frontend ..."
if [ -f $flotilla_dir/frontend/.env ]; then
echo -e "WARNING: The file '$flotilla_dir/frontend/.env' already exists, it will be overwritten if the operation continues."
echo -e "Is this ok? (Y/n)"
read reply
if [ "$reply" = "n" ] || [ "$reply" = "N" ]; then
echo -e "\nFrontend setup - Aborted!"
frontend_abort="true"
fi
fi
if [ "$frontend_abort" != "true" ]; then
cp $flotilla_dir/frontend/.env.example $flotilla_dir/frontend/.env
echo -e "Created frontend/.env file from frontend/.env.example"
echo -e "Frontend setup - Done!"
fi
echo -e "-----------------------------\n"
#-----------------------------
#-------- BACKEND ------------
echo "-------- BACKEND ------------"
echo -e "Setting up backend ..."
if [ -f $flotilla_dir/.env ]; then
echo -e "WARNING: The file '$flotilla_dir/.env' already exists, it will be overwritten if the operation continues."
echo -e "Is this ok? (Y/n)"
read reply
if [ "$reply" = "n" ] || [ "$reply" = "N" ]; then
echo -e "\nBackend setup - Aborted!\n"
backend_abort="true"
fi
fi
if [ "$backend_abort" != "true" ]; then
echo -e "Flotilla azure client secret needed for backend dockerization."
echo -en "Input Flotilla Azure Client Secret (copy-paste from KeyVault):\n"
while [ true ]
do
read -s az_client_secret
if [ -z "$az_client_secret" ]; then
echo "Azure client secret cannot be empty"
echo "Try again:"
else
break
fi
done
echo "FLOTILLA_CLIENT_SECRET='$az_client_secret'" > $flotilla_dir/.env
echo -e "Added client secret to .env file"
dotnet user-secrets set "AzureAd:ClientSecret" $az_client_secret --project backend/api > /dev/null
echo -e "Added client secret to ASP.NET secret manager"
echo -e "Backup setup - Done!"
echo -e "-----------------------------\n"
fi
#-----------------------------
#--------- BROKER ------------
echo "--------- BROKER ------------"
echo -e "Setting up broker ..."
if [ -f $flotilla_dir/.env ]; then
echo -e "WARNING: The file '$flotilla_dir/.env' already exists, it will be overwritten if the operation continues."
echo -e "Is this ok? (Y/n)"
read reply
if [ "$reply" = "n" ] || [ "$reply" = "N" ]; then
echo -e "\Broker setup - Aborted!\n"
broker_abort="true"
fi
fi
if [ "$broker_abort" != "true" ]; then
echo -e "MQTT TLS Server key needed for the broker to communicate using TLS"
echo -en "Input MQTT broker server key (copy-paste from KeyVault):\n"
read -s broker_server_key
# Save to .env file
echo -e "FLOTILLA_BROKER_SERVER_KEY='$broker_server_key'" >> $flotilla_dir/.env
echo -e "Added broker server key to .env file"
echo -e "Broker setup - Done!"
echo -e "-----------------------------\n"
#-----------------------------
echo -e "Flotilla setup - Done!"
echo -e "-----------------------------"
fi