-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·165 lines (147 loc) · 5.43 KB
/
run.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
#!/bin/bash
# Usando uma lista com botões de rádio com o Zenity
# export CONTAINERS=$(docker ps -a --format "table {{.ID}}\t{{.Image}}\t{{.Names}}")
#----------#
# Welcome #
#----------#
dir=".extras/"
if [ -d "$dir" ];then
zenity --height="120" --width="300" --notification --text "Olá ${LOGNAME}"
sleep 1s
rm -rf .extras/
OCI8=$(zenity --height="360" --width="720" --list --text "Iniciando projeto" \
--radiolist \
--column "" \
--column "Excluir" \
FALSE OCI8_12 FALSE OCI8_18);
if [[ "$OCI8" == "OCI8_12" ]]; then
zenity --height="120" --width="300" --notification --text "Baixando programas..."
mkdir .extras/
cd .extras/
curl -o basic.zip https://www.crecies.gov.br/Dowloads_Arquivos/basic-10.2.0.5.0-linux-x64.zip
curl -o sdk.zip https://www.crecies.gov.br/Dowloads_Arquivos/sdk-10.2.0.5.0-linux-x64.zip
cd ..
else
mkdir .extras/
cp instantclient-basic-linux.x64-18.5.zip .extras/basic.zip
cp instantclient-sdk-linux.x64-18.5.zip .extras/sdk.zip
fi
fi
#zenity --height="120" --width="300" --notification --text "Olá ${LOGNAME} :)"
export PATH = "${PWD}/app"
# REMOÇÃO DE CONTAINERS E IMAGENS
sleep 1s
# Criando variavel global e atribuindo informacoes sobre docker na máquina local
export CONTAINER=$(docker ps -a --format "{{.Names}}")
# Caso tenha algum container
#----------#
# DELETE #
#----------#
if [[ "$CONTAINER" ]]; then
# Criando uma lista de opções para dados serem excluídos
DELETE=$(zenity --height="360" --width="720" --list --text "Iniciando projeto" \
--radiolist \
--column "" \
--column "Excluir" \
FALSE $CONTAINER FALSE Apagar-Tudo);
# Caso a exclusão foi para containers; então
if [[ "${DELETE}" == "${CONTAINER}" ]]; then
print_style "Excluindo ${CONTAINER}...\n" "info";
docker stop "${DELETE}"
docker rm -f "${DELETE}"
docker rmi -f "${DELETE}"
sleep 1s
zenity --height="120" --width="360" --notification --text "\n${CONTAINER} foi apagado!"
exit 0
else
# Caso a exclusão foi para apagar tudo; então
if [[ "${DELETE}" == "Apagar-Tudo" ]]; then
# Pergunta se realmente deseja apagar todos containers
zenity --question --width="420" --text "Tem certeza que deseja apagar todos os containers?"
if [[ $? = 0 ]]; then
print_style "Deletando todos containers...\n" "info"
docker stop $(docker ps -aq)
docker rm -f $(docker ps -aq)
docker rmi -f $(docker images -aq)
sleep 1s
zenity --height="120" --width="300" --notification --text "Todos os containers foram excluidos!"
else
exit 0
fi
else
# Caso nenhum. Saia!
exit 0
fi
fi
fi
# REMOÇÃO DE CONTAINERS E IMAGENS }
# DOCKTERIZANDO AMBIENTE DA APLICAÇÃO
#----------#
# Ambiente #
#----------#
zenity --height="120" --width="300" --notification --text "Iniciando projeto...\n" "info"
ITEM_SELECIONADO=$(zenity --height="360" --width="720" --list --text "Iniciando projeto" \
--radiolist \
--column "Selecionar" \
--column "Métodos" \
TRUE Imagens FALSE Microservicos);
# Caso algum método ágil para desenvolver foi selecionado
if [[ "$ITEM_SELECIONADO" ]]; then
# Caso método seja equivalente a Imagens
if [[ "${ITEM_SELECIONADO}" == "Imagens" ]]; then
# BAIXANDO SEU PROJETO
sleep 1s
zenity --question --width="420" --text "\nDeseja enviar o código fonte do projeto?"
if [[ $? = 0 ]]; then
sleep 1s
zenity --height="120" --width="300" --file-selection
else
IMAGEM_SELECIONADO=$(zenity --height="300" --width="600" --list --text "Escolhendo imagem" \
--radiolist \
--column "Selecionar" \
--column "Imagens" \
TRUE crecies/area-restrita FALSE crecies/infosec FALSE crecies/wordpress FALSE crecies/alfresco FALSE crecies/server);
# Caso a imagem foi realmente selecionada
if [[ "$IMAGEM_SELECIONADO" ]]; then
if [[ "$IMAGEM_SELECIONADO" == "crecies/alfresco" ]];then
docker-compose -f alfresco.docker-compose.yaml up
else
sleep 1s
zenity --height="120" --width="360" --notification --text "\Construindo ${IMAGEM_SELECIONADO}..."
echo "Building imagem...\n" "info";
echo "Building ${IMAGEM_SELECIONADO}..." "info";
docker build -t ${IMAGEM_SELECIONADO} .
#docker run -d --name crecies -v $(pwd):/var/www -p 8000:8000 crecies/laravel-5.8
docker run -d --name crecies -p 8000:8000 ${IMAGEM_SELECIONADO}
docker exec -it crecies bash server.sh
# docker exec -it crecies bash
sleep 1s
zenity --height="120" --width="300" --info --text "\nImagem <b>${IMAGEM_SELECIONADO}</b> \n\construida com sucesso!"
fi
else
# Caso nenhum. Saia!
exit 0
rm -rf .extras/
fi
fi
else
SERVICE_SELECIONADO=$(zenity --height="300" --width="600" --list --text "Ativando serviços" \
--checklist \
--column "Selecionar" \
--column "Serviços" \
FALSE apache FALSE redis FALSE nginx FALSE mysql FALSE oracle FALSE mongo FALSE wordpress FALSE aws);
# Caso método seja equivalente a Microserviços
if [[ "$SERVICE_SELECIONADO" ]]; then
sleep 1s
zenity --height="120" --width="300" --notification --text "\Habilitando <b>${SERVICE_SELECIONADO}</b>..."
echo "Activating services...";
echo "Activating ${SERVICE_SELECIONADO}...";
docker-compose up
docker exec -it app bash
./server.sh
else
# Caso nenhum. Saia!
exit 0
fi
fi
fi