-
Notifications
You must be signed in to change notification settings - Fork 6
/
install_on_aws.sh
executable file
·259 lines (225 loc) · 7.36 KB
/
install_on_aws.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install packages on Ubuntu
install_ubuntu_packages() {
echo "Installing packages for Ubuntu..."
# Add installation steps for Ubuntu here
sudo apt update
sudo apt install -y curl unzip
# Install Terraform if not installed
if ! command_exists terraform; then
echo "Installing Terraform..."
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt update
sudo apt install -y terraform
else
echo "Terraform is already installed."
fi
# Install Helm if not installed
if ! command_exists helm; then
echo "Installing Helm..."
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh
else
echo "Helm is already installed."
fi
# Install AWS CLI if not installed
if ! command_exists aws; then
echo "Installing AWS CLI..."
sudo apt install -y awscli
else
echo "AWS CLI is already installed."
fi
# Install Python 3.7 packages if not installed
if ! command_exists python3.7; then
echo "Installing Python 3.7..."
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.7
else
echo "Python 3.7 is already installed."
fi
}
# Function to install packages on Linux
install_linux_packages() {
echo "Installing packages for Linux..."
# Add installation steps for Linux here
sudo yum update -y
sudo yum install -y curl unzip
# Install Terraform if not installed
if ! command_exists terraform; then
echo "Installing Terraform..."
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum install -y terraform
else
echo "Terraform is already installed."
fi
# Install Helm if not installed
if ! command_exists helm; then
echo "Installing Helm..."
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh
else
echo "Helm is already installed."
fi
# Install AWS CLI if not installed
if ! command_exists aws; then
echo "Installing AWS CLI..."
sudo yum install -y aws-cli
else
echo "AWS CLI is already installed."
fi
# Install Python 3.7 packages if not installed
if ! command_exists python3.7; then
echo "Installing Python 3.7..."
sudo yum install -y python3 python3-devel python3-pip
else
echo "Python 3.7 is already installed."
fi
}
# Function to install packages on MacOS
install_macos_packages() {
echo "Installing packages for MacOS..."
# Add installation steps for MacOS here
echo "Installing packages for macOS..."
brew update
brew install curl unzip
if ! command_exists terraform; then
echo "Installing Terraform..."
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
else
echo "Terraform is already installed."
fi
# Install Helm if not installed
if ! command_exists helm; then
echo "Installing Helm..."
brew install helm
else
echo "Helm is already installed."
fi
# Install AWS CLI if not installed
if ! command_exists aws; then
echo "Installing AWS CLI..."
brew install awscli
else
echo "AWS CLI is already installed."
fi
# Install Python 3.7 packages if not installed
if ! command_exists python3.7; then
echo "Installing Python 3.7..."
brew install [email protected]
else
echo "Python 3.7 is already installed."
fi
}
# Function to install packages on Windows
install_windows_packages() {
echo "Installing packages for Windows..."
# Execute PowerShell script to install Chocolatey
powershell.exe -ExecutionPolicy Bypass -File install_choco.ps1
# Install packages using Chocolatey
choco install -y curl unzip
# Install Terraform if not installed
if ! command_exists terraform; then
echo "Installing Terraform..."
choco install -y terraform
else
echo "Terraform is already installed."
fi
# Install Helm if not installed
if ! command_exists helm; then
echo "Installing Helm..."
choco install -y kubernetes-helm
else
echo "Helm is already installed."
fi
# Install AWS CLI if not installed
if ! command_exists aws; then
echo "Installing AWS CLI..."
choco install -y awscli
else
echo "AWS CLI is already installed."
fi
# Install Python 3.7 packages if not installed
if ! command_exists python3.7; then
echo "Installing Python 3.7..."
choco install -y python --version=3.7
else
echo "Python 3.7 is already installed."
fi
}
# Function to configure AWS credentials
configure_aws_credentials() {
read -p "Enter AWS Access Key ID: " aws_access_key_id
read -p "Enter AWS Secret Access Key: " aws_secret_access_key
read -p "Enter AWS Default Region: " aws_default_region
export AWS_ACCESS_KEY_ID="$aws_access_key_id"
export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
export AWS_DEFAULT_REGION="$aws_default_region"
}
# Function to install AWS dependencies
install_aws_dependencies() {
echo "Installing Using AWS..."
# Add commands to install AWS dependencies
cd AWS || exit
# Configure AWS CLI
configure_aws_credentials
# Run Terraform commands
terraform init
terraform plan
terraform apply -auto-approve
aws eks update-kubeconfig --region $AWS_DEFAULT_REGION --name sbai
cd ../helmcharts || exit
#Installing Databases
helm upgrade -i databases ./databases -n sb-ai-assistant --create-namespace -f global-values.yaml -f global-cloud-values.yaml
# Install ai-assistant app
helm upgrade -i applications ./applications -n sb-ai-assistant --create-namespace -f global-values.yaml -f global-cloud-values.yaml
}
# Function to run setup based on user's OS selection
run_os_setup() {
case $os_selection in
1)
echo "Selected operating system: Ubuntu"
install_ubuntu_packages
;;
2)
echo "Selected operating system: Linux"
install_linux_packages
;;
3)
echo "Selected operating system: MacOS"
install_macos_packages
;;
4)
echo "Selected operating system: Windows"
install_windows_packages
;;
*)
echo "Invalid option. Please select a valid option."
exit 1
;;
esac
}
# Ask user for their operating system
echo "Select your operating system:"
echo "1. Ubuntu"
echo "2. Linux"
echo "3. MacOS"
echo "4. Windows"
read -p "Enter your choice (1-4): " os_selection
# Run setup based on user's OS selection
run_os_setup
# Install AWS dependencies
install_aws_dependencies
# Print completion message
echo "Package has been deployed successfully"