Skip to content

Commit 26c3bd8

Browse files
committed
fix(installation): create MyBash for scripts
1 parent c7eb0a9 commit 26c3bd8

File tree

3 files changed

+46
-19
lines changed

3 files changed

+46
-19
lines changed

app/media/MyBash/bash.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!bin/bash
2+
3+
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
4+
5+
wget -O- https://apt.releases.hashicorp.com/gpg | \
6+
gpg --dearmor | \
7+
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
8+
9+
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
10+
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
11+
sudo tee /etc/apt/sources.list.d/hashicorp.list
12+
13+
sudo apt update
14+
15+
sudo apt-get install terraform

app/routes/terraform.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ async def IaC_bugfix_generation(request:IaCBugfixInput) -> Output:
5252
@app.post("/api/IaC-install/")
5353
async def IaC_install_generation(request:IaCInstallationInput) -> Output:
5454
if os.environ.get("TEST"):
55-
return Output(output='apt-get install xyz \n apt-get update (covert them to shell file output)')
56-
selected_script = select_install(request)
57-
return Output(output=selected_script)
55+
return Output(output='nothing special')
56+
select_install(request)
57+
return Output(output="pk")
5858

5959
@app.post("/api/IaC-template/docker")
6060
async def IaC_template_generation_docker(request:IaCTemplateGenerationDocker) -> Output:

app/template_generators/terraform/Installation/main.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,43 @@
1+
import os
2+
import shutil
13

4+
5+
def create_MyBash_directory():
6+
7+
dir = 'app/media/MyBash'
8+
9+
10+
if not os.path.exists(dir):
11+
os.makedirs(dir)
12+
os.path.join(dir, 'bash.sh')
13+
14+
15+
216
def select_install(input):
17+
create_MyBash_directory()
318

419
match input.os:
520

21+
622
case "Ubuntu":
7-
with open("app/media/Installation_base/Terraform/ubuntu.sh", 'r') as file:
8-
file_content = file.read()
9-
10-
return file_content
23+
source = 'app/media/Installation_base/Terraform/ubuntu.sh'
24+
dest = 'app/media/MyBash/bash.sh'
25+
shutil.copyfile(source, dest)
1126

1227
case "Fedora":
13-
with open("app/media/Installation_base/Terraform/fedora.sh", 'r') as file:
14-
file_content = file.read()
15-
16-
return file_content
28+
source = 'app/media/Installation_base/Terraform/fedora.sh'
29+
dest = 'app/media/MyBash/bash.sh'
30+
shutil.copyfile(source, dest)
1731

1832
case "Centos":
19-
with open("app/media/Installation_base/Terraform/centos.sh", 'r') as file:
20-
file_content = file.read()
21-
22-
return file_content
33+
source = 'app/media/Installation_base/Terraform/centos.sh'
34+
dest = 'app/media/MyBash/bash.sh'
35+
shutil.copyfile(source, dest)
2336

2437
case "Amazon_linux":
25-
with open("app/media/Installation_base/Terraform/amazon_linux.sh", 'r') as file:
26-
file_content = file.read()
27-
28-
return file_content
38+
source = 'app/media/Installation_base/Terraform/amazon_linux.sh'
39+
dest = 'app/media/MyBash/bash.sh'
40+
shutil.copyfile(source, dest)
2941
case _:
3042
raise ValueError()
3143

0 commit comments

Comments
 (0)