-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·154 lines (142 loc) · 3.36 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
set -e
WORKING_DIR=$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
export WORKING_DIR
function setEnvironmentVariables() {
echo ""
read -r -p 'Enter the <Environment> to deploy the Hiperium service: [dev] ' env_name
echo ""
echo "Wait a moment please..."
if [ -z "$env_name" ]; then
AWS_WORKLOADS_ENV='dev'
else
AWS_WORKLOADS_ENV=$(echo "$env_name" | tr '[:upper:]' '[:lower:]')
fi
export AWS_WORKLOADS_ENV
### WORKLOADS PROFILE
AWS_WORKLOADS_PROFILE="city-$AWS_WORKLOADS_ENV"
export AWS_WORKLOADS_PROFILE
"$WORKING_DIR"/utils/scripts/common/verify-aws-profile-existence.sh "$AWS_WORKLOADS_PROFILE"
### AWS ACCOUNTS
AWS_WORKLOADS_ACCOUNT_ID=$(aws configure get sso_account_id --profile "$AWS_WORKLOADS_PROFILE")
export AWS_WORKLOADS_ACCOUNT_ID
### AWS REGIONS
AWS_WORKLOADS_REGION=$(aws configure get region --profile "$AWS_WORKLOADS_PROFILE")
export AWS_WORKLOADS_REGION
}
helperMenu() {
echo "
*********************************************
**************** Helper Menu ****************
*********************************************
b) Prune Docker System.
c) Remaining Session Time.
d) Print Environment Variables.
---------------------------------------------
r) Return.
q) Quit.
"
read -r -p 'Choose an option: ' option
case $option in
[Bb])
clear
"$WORKING_DIR"/utils/scripts/common/docker-system-prune.sh
clear
echo ""
echo "DONE!"
helperMenu
;;
[Cc])
clear
printRemainingSessionTime
echo ""
read -r -p 'Press [Enter] key to continue...'
clear
echo "DONE!"
helperMenu
;;
[Dd])
clear
echo
"$WORKING_DIR"/utils/scripts/common/print-global-variables.sh
clear
echo "DONE!"
helperMenu
;;
[Rr])
clear
menu
;;
[Qq])
clear
echo ""
echo "DONE!"
echo ""
exit 0
;;
*)
clear
echo 'Wrong option.'
helperMenu
;;
esac
}
function printRemainingSessionTime() {
clear
"$WORKING_DIR"/utils/scripts/common/verify-remaining-session-time.sh "true"
}
menu() {
echo "
*******************************************
**************** Main Menu ****************
*******************************************
1) Docker-Compose.
2) Create Backend.
3) Delete Backend.
-------------------------------------------
h) Helper Menu.
q) Quit.
"
read -r -p 'Choose an option: ' option
case $option in
[Hh])
clear
helperMenu
;;
1)
"$WORKING_DIR"/utils/scripts/1_deploy-docker-compose.sh
;;
2)
printRemainingSessionTime
"$WORKING_DIR"/utils/scripts/2_create-sam-backend.sh
clear
echo ""
echo "DONE!"
menu
;;
3)
printRemainingSessionTime
"$WORKING_DIR"/utils/scripts/3_delete-sam-backend.sh
clear
echo ""
echo "DONE!"
menu
;;
[Qq])
clear
echo ""
echo "DONE!"
exit 0
;;
*)
clear
echo 'Wrong option.'
menu
;;
esac
}
#### Main function ####
clear
setEnvironmentVariables
clear
menu