Commit b90e9f726805610baacb253fea825d35ca6810e4
0 parents
Exists in
master
Initial commit! By Questor
Showing
40 changed files
with
2354 additions
and
0 deletions
Show diff stats
No preview for this file type
1 | +++ a/ez_i.sh | |
... | ... | @@ -0,0 +1,823 @@ |
1 | +#!/bin/bash | |
2 | +: 'Trata-se de um módulo que oferece uma série de funcionalidades para | |
3 | +criar um instalador usando "bash". | |
4 | + | |
5 | +Apache License | |
6 | +Version 2.0, January 2004 | |
7 | +http://www.apache.org/licenses/ | |
8 | +Copyright 2016 Eduardo Lúcio Amorim Costa | |
9 | +' | |
10 | + | |
11 | +# NOTE: Obtêm a pasta do script atual para que seja usado como | |
12 | +# caminho base/referência durante a instalação! By Questor | |
13 | +EZ_I_DIR_V="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
14 | + | |
15 | +# NOTE: Quando setado faz "ez_i" desabilitar algumas funções, | |
16 | +# notadamente aquelas que envolvem "perguntas ao usuário" e as | |
17 | +# gráficas! By Questor | |
18 | +EZ_I_SKIP_ON_V=0 | |
19 | + | |
20 | +# > -------------------------------------------------------------------------- | |
21 | +# UTILITÁRIOS! | |
22 | +# -------------------------------------- | |
23 | + | |
24 | +f_enter_to_cont() { | |
25 | + : 'Solicitar ao usuário que pressione enter para continuar. | |
26 | + | |
27 | + Args: | |
28 | + INFO_P (Optional[str]): Se informado apresenta uma mensagem ao | |
29 | + usuário. | |
30 | + ' | |
31 | + | |
32 | + INFO_P=$1 | |
33 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
34 | + return 0 | |
35 | + fi | |
36 | + | |
37 | + if [ ! -z "$INFO_P" ] ; then | |
38 | + f_div_section | |
39 | + echo "$INFO_P" | |
40 | + f_div_section | |
41 | + fi | |
42 | + | |
43 | + read -p "Press enter to continue..." nothing | |
44 | +} | |
45 | + | |
46 | +GET_USR_INPUT_R="" | |
47 | +f_get_usr_input() { | |
48 | + : 'Obter entradas digitadas pelo usuário. | |
49 | + | |
50 | + Permite autocomplete (tab). Enter para submeter a entrada. | |
51 | + | |
52 | + Args: | |
53 | + QUESTION_P (str): Pergunta a ser feita ao usuário. | |
54 | + ALLOW_EMPTY_P (Optional[int]): 0 - Não permite valor vazio; 1 - Permite | |
55 | + valor vazio. Padrão 0. | |
56 | + | |
57 | + Returns: | |
58 | + GET_USR_INPUT_R (str): Entrada digitada pelo usuário. | |
59 | + ' | |
60 | + | |
61 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
62 | + return 0 | |
63 | + fi | |
64 | + QUESTION_P=$1 | |
65 | + ALLOW_EMPTY_P=$2 | |
66 | + if [ -z "$ALLOW_EMPTY_P" ] ; then | |
67 | + ALLOW_EMPTY_P=0 | |
68 | + fi | |
69 | + GET_USR_INPUT_R="" | |
70 | + read -e -r -p "$QUESTION_P (use enter to confirm): " RESP_V | |
71 | + if [ -n "$RESP_V" ] ; then | |
72 | + GET_USR_INPUT_R="$RESP_V" | |
73 | + elif [ ${ALLOW_EMPTY_P} -eq 0 ] ; then | |
74 | + f_get_usr_input "$QUESTION_P" 0 | |
75 | + fi | |
76 | +} | |
77 | + | |
78 | +F_EZ_SED_ECP_R="" | |
79 | +f_ez_sed_ecp() { | |
80 | + : '"Escapar" strings para o comando "sed". | |
81 | + | |
82 | + Como há muitas semelhanças entre o escape para "sed" ("f_ez_sed") e | |
83 | + escape para "grep" ("f_fl_cont_str") optei por colocar essa | |
84 | + função como utilitária para as outras duas citadas. | |
85 | + | |
86 | + Args: | |
87 | + VAL_TO_ECP (str): Valor a ser "escapado". | |
88 | + DONT_ECP_NL (Optional[int]): 0 - Não "escapa" "\n" (quebra de | |
89 | + linha); 1 - "Escapa" "\n". Padrão 1. | |
90 | + DONT_ECP_SQ (Optional[int]): 0 - Não "escapa" "'" (aspas | |
91 | + simples); 1 - "Escapa" "'". Padrão 0. NOTE: Usado apenas pela | |
92 | + função "f_fl_cont_str". | |
93 | + | |
94 | + Returns: | |
95 | + F_EZ_SED_ECP_R (str): Valor "escapado". | |
96 | + ' | |
97 | + | |
98 | + VAL_TO_ECP=$1 | |
99 | + DONT_ECP_NL=$2 | |
100 | + if [ -z "$DONT_ECP_NL" ] ; then | |
101 | + DONT_ECP_NL=1 | |
102 | + fi | |
103 | + DONT_ECP_SQ=$3 | |
104 | + if [ -z "$DONT_ECP_SQ" ] ; then | |
105 | + DONT_ECP_SQ=0 | |
106 | + fi | |
107 | + F_EZ_SED_ECP_R=$VAL_TO_ECP | |
108 | + if [ ${DONT_ECP_NL} -eq 1 ] ; then | |
109 | + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/\\n/C0673CECED2D4A8FBA90C9B92B9508A8/g') | |
110 | + fi | |
111 | + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/[]\/$*.^|[]/\\&/g') | |
112 | + if [ ${DONT_ECP_SQ} -eq 0 ] ; then | |
113 | + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed "s/'/\\\x27/g") | |
114 | + fi | |
115 | + if [ ${DONT_ECP_NL} -eq 1 ] ; then | |
116 | + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/C0673CECED2D4A8FBA90C9B92B9508A8/\\n/g') | |
117 | + fi | |
118 | +} | |
119 | + | |
120 | +f_ez_sed() { | |
121 | + : 'Facilitar o uso da funcionalidade "sed". | |
122 | + | |
123 | + Args: | |
124 | + TARGET (str): Valor a ser substituído por pelo valor de REPLACE. | |
125 | + REPLACE (str): Valor que irá substituir TARGET. | |
126 | + FILE (str): Arquivo no qual será feita a substituição. | |
127 | + ALL_OCCUR (Optional[int]): 0 - Fazer replace apenas na primeira | |
128 | + ocorrência; 1 - Fazer replace em todas as ocorrências. Padrão 0. | |
129 | + DONT_ESCAPE (Optional[int]): 0 - Faz escape das strings em | |
130 | + TARGET e REPLACE; 1 - Não faz escape das strings em TARGET e | |
131 | + REPLACE. Padrão 0. | |
132 | + DONT_ECP_NL (Optional[int]): 1 - Não "escapa" "\n" (quebra de | |
133 | + linha); 0 - "Escapa" "\n". Padrão 1. | |
134 | + REMOVE_LN (Optional[int]): 1 - Remove a linha que possui o | |
135 | + valor em TARGET; 0 - Faz o replace convencional. Padrão 0. | |
136 | + ' | |
137 | + | |
138 | + FILE=$3 | |
139 | + ALL_OCCUR=$4 | |
140 | + if [ -z "$ALL_OCCUR" ] ; then | |
141 | + ALL_OCCUR=0 | |
142 | + fi | |
143 | + DONT_ESCAPE=$5 | |
144 | + if [ -z "$DONT_ESCAPE" ] ; then | |
145 | + DONT_ESCAPE=0 | |
146 | + fi | |
147 | + DONT_ECP_NL=$6 | |
148 | + if [ -z "$DONT_ECP_NL" ] ; then | |
149 | + DONT_ECP_NL=1 | |
150 | + fi | |
151 | + REMOVE_LN=$7 | |
152 | + if [ -z "$REMOVE_LN" ] ; then | |
153 | + REMOVE_LN=0 | |
154 | + fi | |
155 | + if [ ${DONT_ESCAPE} -eq 1 ] ; then | |
156 | + TARGET=$1 | |
157 | + REPLACE=$2 | |
158 | + else | |
159 | + f_ez_sed_ecp "$1" $DONT_ECP_NL | |
160 | + TARGET=$F_EZ_SED_ECP_R | |
161 | + f_ez_sed_ecp "$2" $DONT_ECP_NL | |
162 | + REPLACE=$F_EZ_SED_ECP_R | |
163 | + fi | |
164 | + if [ ${REMOVE_LN} -eq 1 ] ; then | |
165 | + if [ ${ALL_OCCUR} -eq 0 ] ; then | |
166 | + SED_RPL="'0,/$TARGET/{//d;}'" | |
167 | + else | |
168 | + SED_RPL="'/$TARGET/d'" | |
169 | + fi | |
170 | + eval "sed -i $SED_RPL $FILE" | |
171 | + else | |
172 | + if [ ${ALL_OCCUR} -eq 0 ] ; then | |
173 | + SED_RPL="'0,/$TARGET/s//$REPLACE/g'" | |
174 | + else | |
175 | + SED_RPL="'s/$TARGET/$REPLACE/g'" | |
176 | + fi | |
177 | + eval "sed -i $SED_RPL $FILE" | |
178 | + fi | |
179 | +} | |
180 | + | |
181 | +FL_CONT_STR_R=0 | |
182 | +f_fl_cont_str() { | |
183 | + : 'Checar se um arquivo contêm determinada string. | |
184 | + | |
185 | + Args: | |
186 | + STR_TO_CH (str): Valor de string a ser verificado. | |
187 | + FILE (str): Arquivo no qual será feita a verificação. | |
188 | + COND_MSG_P (Optional[str]): Mensagem a ser exibida se | |
189 | + verdadeira a verificação. Se vazio ou não informado não será | |
190 | + exibida mensagem. | |
191 | + CHK_INVERT (Optional[int]): Inverter a lógica da checagem. | |
192 | + Padrão 0. | |
193 | + DONT_ESCAPE (Optional[int]): 0 - Faz escape da string em | |
194 | + STR_TO_CH; 1 - Não faz escape das strings em STR_TO_CH. Padrão 0. | |
195 | + DONT_ECP_NL (Optional[int]): 1 - Não "escapa" "\n" (quebra de | |
196 | + linha); 0 - "Escapa" "\n". Padrão 1. | |
197 | + | |
198 | + Returns: | |
199 | + FL_CONT_STR_R (int): 1 - Se verdadeiro para a condição | |
200 | + analisada; 0 - Se falso para a condição analisada. | |
201 | + ' | |
202 | + | |
203 | + STR_TO_CH=$1 | |
204 | + FILE=$2 | |
205 | + COND_MSG_P=$3 | |
206 | + CHK_INVERT=$4 | |
207 | + DONT_ESCAPE=$5 | |
208 | + | |
209 | + if [ -z "$DONT_ESCAPE" ] ; then | |
210 | + DONT_ESCAPE=0 | |
211 | + fi | |
212 | + if [ ${DONT_ESCAPE} -eq 0 ] ; then | |
213 | + DONT_ECP_NL=$6 | |
214 | + if [ -z "$DONT_ECP_NL" ] ; then | |
215 | + DONT_ECP_NL=1 | |
216 | + fi | |
217 | + f_ez_sed_ecp "$STR_TO_CH" $DONT_ECP_NL 1 | |
218 | + STR_TO_CH=$F_EZ_SED_ECP_R | |
219 | + fi | |
220 | + | |
221 | + if [ -z "$CHK_INVERT" ] ; then | |
222 | + CHK_INVERT=0 | |
223 | + fi | |
224 | + FL_CONT_STR_R=0 | |
225 | + if [ ${CHK_INVERT} -eq 0 ] ; then | |
226 | + if grep -q "$STR_TO_CH" "$FILE"; then | |
227 | + FL_CONT_STR_R=1 | |
228 | + fi | |
229 | + else | |
230 | + if ! grep -q "$STR_TO_CH" "$FILE"; then | |
231 | + FL_CONT_STR_R=1 | |
232 | + fi | |
233 | + fi | |
234 | + if [ ${EZ_I_SKIP_ON_V} -eq 0 ] && [ ${FL_CONT_STR_R} -eq 1 ] && [ ! -z "$COND_MSG_P" ] ; then | |
235 | + f_div_section | |
236 | + echo "$COND_MSG_P" | |
237 | + f_div_section | |
238 | + f_enter_to_cont | |
239 | + fi | |
240 | +} | |
241 | + | |
242 | +CHK_FD_FL_R=0 | |
243 | +f_chk_fd_fl() { | |
244 | + : 'Verificar se determinado diretório ou arquivo existe. | |
245 | + | |
246 | + Args: | |
247 | + TARGET (str): Diretório ou arquivo qual se quer verificar. | |
248 | + CHK_TYPE (str): "d" - Checar por diretório; "f" - Checar por | |
249 | + arquivo. | |
250 | + | |
251 | + Returns: | |
252 | + CHK_FD_FL_R (int): 1 - True; 0 - False. | |
253 | + ' | |
254 | + | |
255 | + CHK_FD_FL_R=0 | |
256 | + TARGET=$1 | |
257 | + CHK_TYPE=$2 | |
258 | + if [ "$CHK_TYPE" == "f" ] ; then | |
259 | + if [ -f "$TARGET" ] ; then | |
260 | + CHK_FD_FL_R=1 | |
261 | + fi | |
262 | + fi | |
263 | + if [ "$CHK_TYPE" == "d" ] ; then | |
264 | + if [ -d "$TARGET" ] ; then | |
265 | + CHK_FD_FL_R=1 | |
266 | + fi | |
267 | + fi | |
268 | +} | |
269 | + | |
270 | +F_PACK_IS_INST_R=0 | |
271 | +f_pack_is_inst() { | |
272 | + : 'Checar se um pacote está instalado. | |
273 | + | |
274 | + Args: | |
275 | + PACKAGE_NM_P (str): Nome do pacote. | |
276 | + PACK_MANAG (str): Tipo de gerenciador de pacotes. Apenas yum é | |
277 | + suportado. Em caso diverso o script exibe erro e para. | |
278 | + EXIST_MSG_P (Optional[str]): Mensagem a ser exibida se o | |
279 | + pacote já estiver instalado. Se vazio ou não informado não será | |
280 | + exibida mensagem. | |
281 | + SKIP_MSG_P (Optional[int]): Omite a mensagem. Padrão 0. | |
282 | + | |
283 | + Returns: | |
284 | + F_PACK_IS_INST_R (int): 1 - Instalado; 0 - Não instalado. | |
285 | + ' | |
286 | + | |
287 | + PACKAGE_NM_P=$1 | |
288 | + PACK_MANAG=$2 | |
289 | + EXIST_MSG_P=$3 | |
290 | + SKIP_MSG_P=$4 | |
291 | + | |
292 | + if [ -z "$SKIP_MSG_P" ] ; then | |
293 | + SKIP_MSG_P=0 | |
294 | + fi | |
295 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
296 | + SKIP_MSG_P=1 | |
297 | + fi | |
298 | + | |
299 | + F_PACK_IS_INST_R=0 | |
300 | + if [ "$PACK_MANAG" == "yum" ] ; then | |
301 | + if yum list installed "$PACKAGE_NM_P" >/dev/null 2>&1; then | |
302 | + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$EXIST_MSG_P" ] ; then | |
303 | + f_div_section | |
304 | + echo "$EXIST_MSG_P" | |
305 | + f_div_section | |
306 | + f_enter_to_cont | |
307 | + fi | |
308 | + F_PACK_IS_INST_R=1 | |
309 | + else | |
310 | + F_PACK_IS_INST_R=0 | |
311 | + fi | |
312 | + else | |
313 | + f_div_section | |
314 | + echo "ERROR! Not implemented for \"$PACK_MANAG\"!" | |
315 | + f_div_section | |
316 | + f_enter_to_cont | |
317 | + fi | |
318 | +} | |
319 | + | |
320 | +F_CHK_BY_PATH_HLP_R=0 | |
321 | +f_chk_by_path_hlp() { | |
322 | + : 'Checar se um aplicativo/pacote/arquivo está presente/instalado | |
323 | + verificando-o através do seu caminho físico informando. | |
324 | + | |
325 | + Args: | |
326 | + PATH_VER_P (str): Caminho físico para o aplicativo/pacote. | |
327 | + VER_TYPE_P (str): Se o caminho físico é para um diretório ("d") | |
328 | + ou arquivo ("f"). | |
329 | + EXIST_MSG_P (Optional[str]): Mensagem a ser "printada" caso o | |
330 | + aplicativo/pacote/arquivo exista. Se não informado ou vazio não | |
331 | + exibe a mensagem. | |
332 | + SKIP_MSG_P (Optional[int]): Não exibir mensagem. | |
333 | + | |
334 | + Returns: | |
335 | + F_CHK_BY_PATH_HLP_R (int): 0 - Não existe; 1 - Existe | |
336 | + ("printa" menssagem contida em EXIST_MSG_P). | |
337 | + ' | |
338 | + | |
339 | + PATH_VER_P=$1 | |
340 | + VER_TYPE_P=$2 | |
341 | + EXIST_MSG_P=$3 | |
342 | + SKIP_MSG_P=$4 | |
343 | + if [ -z "$SKIP_MSG_P" ] ; then | |
344 | + SKIP_MSG_P=0 | |
345 | + fi | |
346 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
347 | + SKIP_MSG_P=1 | |
348 | + fi | |
349 | + | |
350 | + F_CHK_BY_PATH_HLP_R=0 | |
351 | + f_chk_fd_fl "$PATH_VER_P" "$VER_TYPE_P" | |
352 | + if [ ${CHK_FD_FL_R} -eq 0 ] ; then | |
353 | + F_CHK_BY_PATH_HLP_R=0 | |
354 | + else | |
355 | + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$EXIST_MSG_P" ]; then | |
356 | + f_div_section | |
357 | + echo "$EXIST_MSG_P" | |
358 | + f_div_section | |
359 | + f_enter_to_cont | |
360 | + fi | |
361 | + F_CHK_BY_PATH_HLP_R=1 | |
362 | + fi | |
363 | +} | |
364 | + | |
365 | +F_CHK_IPTABLES_R=0 | |
366 | +f_chk_iptables() { | |
367 | + : 'Fazer verificações usando "iptables". | |
368 | + | |
369 | + Trata-se de um utilitário para fazer verificações diversas usando o | |
370 | + comando "iptables" NORMALMENTE CHECAR DE DETERMINADA PORTA ESTÁ | |
371 | + ABERTA. | |
372 | + | |
373 | + Ex 1.: f_chk_iptables 80 | |
374 | + Ex 2.: f_chk_iptables 80 "Já está aberta!" | |
375 | + Ex 3.: f_chk_iptables 80 "Já está aberta!" 0 "ACCEPT" "tcp" "NEW" | |
376 | + Ex 4.: f_chk_iptables 80 "Já está aberta!" 0 "ACCEPT" "tcp" "NEW" 5 | |
377 | + | |
378 | + Args: | |
379 | + PORT_P (int): Porta a ser verificada. | |
380 | + MSG_P (Optional[str]): Mensagem a ser exibida em caso de | |
381 | + verdadeiro para a verificação (normalmente porta aberta). Se vazio | |
382 | + ou não informado não será exibida mensagem. | |
383 | + SKIP_MSG_P (Optional[int]): Não exibir mensagem. | |
384 | + Padrão 0. | |
385 | + TARGET_P (Optional[str]): Padrão "ACCEPT". | |
386 | + PROT_P (Optional[str]): Padrão "tcp". | |
387 | + STATE_P (str): Padrão "". | |
388 | + POS_IN_CHAIN_P (int): Padrão "". | |
389 | + | |
390 | + Returns: | |
391 | + F_CHK_IPTABLES_R (int): 1 - Verdadeiro para a verificação; | |
392 | + 0 - Falso para a verificação. | |
393 | + ' | |
394 | + | |
395 | + PORT_P=$1 | |
396 | + MSG_P=$2 | |
397 | + SKIP_MSG_P=$3 | |
398 | + | |
399 | + if [ -z "$SKIP_MSG_P" ] ; then | |
400 | + SKIP_MSG_P=0 | |
401 | + fi | |
402 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
403 | + SKIP_MSG_P=1 | |
404 | + fi | |
405 | + | |
406 | + TARGET_P=$4 | |
407 | + if [ -z "$TARGET_P" ] ; then | |
408 | + TARGET_P="ACCEPT" | |
409 | + fi | |
410 | + PROT_P=$5 | |
411 | + if [ -z "$PROT_P" ] ; then | |
412 | + PROT_P="tcp" | |
413 | + fi | |
414 | + STATE_P=$6 | |
415 | + if [ -z "$STATE_P" ] ; then | |
416 | + STATE_P="" | |
417 | + else | |
418 | + STATE_P="state $STATE_P " | |
419 | + fi | |
420 | + POS_IN_CHAIN_P=$7 | |
421 | + if [ -z "$POS_IN_CHAIN_P" ] ; then | |
422 | + POS_IN_CHAIN_P="" | |
423 | + else | |
424 | + POS_IN_CHAIN_P=$(printf "%-9s" $POS_IN_CHAIN_P) | |
425 | + fi | |
426 | + GREP_OUT=$(iptables -vnL --line-numbers | grep "$POS_IN_CHAIN_P" | grep "$TARGET_P" | grep "$PROT_P" | grep "$STATE_P$PROT_P dpt:$PORT_P") | |
427 | + if [ $? -eq 1 ] ; then | |
428 | + F_CHK_IPTABLES_R=1 | |
429 | + else | |
430 | + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$MSG_P" ] ; then | |
431 | + f_div_section | |
432 | + echo "$MSG_P" | |
433 | + f_div_section | |
434 | + f_enter_to_cont | |
435 | + fi | |
436 | + F_CHK_IPTABLES_R=0 | |
437 | + fi | |
438 | +} | |
439 | + | |
440 | +F_IS_NOT_RUNNING_R=0 | |
441 | +f_is_not_running() { | |
442 | + : 'Checar de determinado processo (pode ser um serviço) está | |
443 | + rodando. | |
444 | + | |
445 | + Args: | |
446 | + PROC_NM_P (str): Nome do processo (pode ser um serviço). | |
447 | + COND_MSG_P (Optional[str]): Mensagem a ser exibida se | |
448 | + verdadeira a verificação. Se vazio ou não informado não será | |
449 | + exibida mensagem. | |
450 | + CHK_INVERT (Optional[int]): Inverter a lógica da checagem. | |
451 | + Padrão 0. | |
452 | + | |
453 | + Returns: | |
454 | + F_IS_NOT_RUNNING_R (int): 1 - Se verdadeiro para a condição | |
455 | + analisada; 0 - Se falso para a condição analisada. | |
456 | + ' | |
457 | + | |
458 | + PROC_NM_P=$1 | |
459 | + COND_MSG_P=$2 | |
460 | + CHK_INVERT=$3 | |
461 | + if [ -z "$CHK_INVERT" ] ; then | |
462 | + CHK_INVERT=0 | |
463 | + fi | |
464 | + F_IS_NOT_RUNNING_R=0 | |
465 | + # NOTE: A verificação "grep -v grep" é para que ele não dê positivo | |
466 | + # para o próprio comando grep! By Questor | |
467 | + F_IS_NOT_RUNNING_R=0 | |
468 | + if [ ${CHK_INVERT} -eq 0 ] ; then | |
469 | + if ! ps aux | grep -v "grep" | grep "$PROC_NM_P" > /dev/null ; then | |
470 | + F_IS_NOT_RUNNING_R=1 | |
471 | + fi | |
472 | + else | |
473 | + if ps aux | grep -v "grep" | grep "$PROC_NM_P" > /dev/null ; then | |
474 | + F_IS_NOT_RUNNING_R=1 | |
475 | + fi | |
476 | + fi | |
477 | + if [ ${EZ_I_SKIP_ON_V} -eq 0 ] && [ ${F_IS_NOT_RUNNING_R} -eq 1 ] && [ ! -z "$COND_MSG_P" ] ; then | |
478 | + f_div_section | |
479 | + echo "$COND_MSG_P" | |
480 | + f_div_section | |
481 | + f_enter_to_cont | |
482 | + fi | |
483 | +} | |
484 | + | |
485 | +F_GET_STDERR_R="" | |
486 | +F_GET_STDOUT_R="" | |
487 | +f_get_stderr_stdout() { | |
488 | + : 'Executar um comando e colocar a saída de stderr e stdout nas | |
489 | + variáveis "F_GET_STDERR_R" e "F_GET_STDOUT_R"!. | |
490 | + | |
491 | + Args: | |
492 | + CMD_TO_EXEC (str): Comando a ser executado. | |
493 | + | |
494 | + Returns: | |
495 | + F_GET_STDERR_R (str): Saída para stderr. | |
496 | + F_GET_STDOUT_R (str): Saída para stdout. | |
497 | + ' | |
498 | + | |
499 | + CMD_TO_EXEC=$1 | |
500 | + F_GET_STDERR_R="" | |
501 | + F_GET_STDOUT_R="" | |
502 | + unset t_std t_err | |
503 | + eval "$( eval "$CMD_TO_EXEC" 2> >(t_err=$(cat); typeset -p t_err) > >(t_std=$(cat); typeset -p t_std) )" | |
504 | + F_GET_STDERR_R=$t_err | |
505 | + F_GET_STDOUT_R=$t_std | |
506 | +} | |
507 | + | |
508 | +F_BAK_PATH_R="" | |
509 | +F_BAK_MD_R=0 | |
510 | +f_ez_mv_bak() { | |
511 | + : 'Modifica o nome de um arquivo ou pasta para um nome de backup. | |
512 | + | |
513 | + Adiciona um sufixo ao nome no formato: "-D%Y-%m-%d-T%H-%M-%S.bak". | |
514 | + | |
515 | + Args: | |
516 | + TARGET (str): Caminho para o arquivo ou pasta alvo. | |
517 | + CONF_MSG_P (Optional[str]): Verificar se o usuário deseja ou | |
518 | + não backup. Se vazio ou não informado não será exibida mensagem. | |
519 | + SKIP_MSG_P (Optional[int]): Não exibir mensagem. Padrão 0. | |
520 | + | |
521 | + Returns: | |
522 | + F_BAK_PATH_R (str): Caminho para o arquivo ou pasta alvo com o | |
523 | + novo nome. | |
524 | + F_BAK_NAME_R (str): Nome do arquivo recém criado. | |
525 | + F_BAK_MD_R (int): 1 - Backup realizado; 0 - Backup não | |
526 | + realizado. | |
527 | + ' | |
528 | + | |
529 | + TARGET=$1 | |
530 | + CONF_MSG_P=$2 | |
531 | + SKIP_MSG_P=$3 | |
532 | + if [ -z "$SKIP_MSG_P" ] ; then | |
533 | + SKIP_MSG_P=0 | |
534 | + fi | |
535 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
536 | + SKIP_MSG_P=1 | |
537 | + fi | |
538 | + | |
539 | + | |
540 | + MK_BAK=1 | |
541 | + F_BAK_PATH_R="" | |
542 | + F_BAK_NAME_R="" | |
543 | + F_BAK_MD_R=0 | |
544 | + | |
545 | + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$CONF_MSG_P" ] ; then | |
546 | + f_div_section | |
547 | + f_yes_no "$CONF_MSG_P" | |
548 | + f_div_section | |
549 | + MK_BAK=$YES_NO_R | |
550 | + fi | |
551 | + if [ ${MK_BAK} -eq 1 ] ; then | |
552 | + SUFFIX=$(date +"-D%Y-%m-%d-T%H-%M-%S.bak") | |
553 | + NEW_NAME="$TARGET$SUFFIX" | |
554 | + mv "$TARGET" "$NEW_NAME" | |
555 | + F_BAK_PATH_R=$NEW_NAME | |
556 | + F_BAK_NAME_R="${NEW_NAME##*/}" | |
557 | + F_BAK_MD_R=1 | |
558 | + fi | |
559 | +} | |
560 | + | |
561 | +f_error_exit() { | |
562 | + : '"Printa" uma mensagem de erro e encerra o instalador. | |
563 | + | |
564 | + Args: | |
565 | + ERROR_CAUSE_P (Optional[str]): Causa do erro. | |
566 | + ' | |
567 | + | |
568 | + ERROR_CAUSE_P=$1 | |
569 | + echo | |
570 | + f_open_section "E R R O R !" | |
571 | + ERROR_MSG_NOW_P="AN ERROR OCCURRED AND THIS INSTALLER WAS CLOSED!" | |
572 | + if [ ! -z "$ERROR_CAUSE_P" ] ; then | |
573 | + ERROR_MSG_NOW_P="$ERROR_MSG_NOW_P ERROR: \"$ERROR_CAUSE_P\"" | |
574 | + fi | |
575 | + echo "$ERROR_MSG_NOW_P" | |
576 | + echo | |
577 | + f_close_section | |
578 | + exit 1 | |
579 | +} | |
580 | + | |
581 | +f_continue() { | |
582 | + : 'Questionar ao usuário se deseja continuar ou parar a instalação. | |
583 | + | |
584 | + Args: | |
585 | + NOTE_P (Optional[str]): Informações adicionais ao usuário. | |
586 | + ' | |
587 | + | |
588 | + NOTE_P=$1 | |
589 | + f_div_section | |
590 | + if [ -z "$NOTE_P" ] ; then | |
591 | + NOTE_P="" | |
592 | + else | |
593 | + NOTE_P=" (NOTE: \"$NOTE_P\")" | |
594 | + fi | |
595 | + | |
596 | + f_yes_no "CONTINUE? (USE \"n\" TO STOP THIS INSTALLER)$NOTE_P" | |
597 | + f_div_section | |
598 | + if [ ${YES_NO_R} -eq 0 ] ; then | |
599 | + exit 0 | |
600 | + fi | |
601 | +} | |
602 | + | |
603 | + | |
604 | +# < -------------------------------------------------------------------------- | |
605 | + | |
606 | +# > -------------------------------------------------------------------------- | |
607 | +# GRAFICO! | |
608 | +# -------------------------------------- | |
609 | + | |
610 | +f_indent() { | |
611 | + : 'Definir uma tabulação para uma string informada. | |
612 | + | |
613 | + Exemplo de uso: echo "<STR_VALUE>" | f_indent 4 | |
614 | + | |
615 | + Args: | |
616 | + LEVEL_P (int): 2, 4 ou 8 espaços. | |
617 | + ' | |
618 | + | |
619 | + LEVEL_P=$1 | |
620 | + if [ ${LEVEL_P} -eq 2 ] ; then | |
621 | + sed 's/^/ /'; | |
622 | + fi | |
623 | + if [ ${LEVEL_P} -eq 4 ] ; then | |
624 | + sed 's/^/ /'; | |
625 | + fi | |
626 | + if [ ${LEVEL_P} -eq 8 ] ; then | |
627 | + sed 's/^/ /'; | |
628 | + fi | |
629 | +} | |
630 | + | |
631 | +f_open_section() { | |
632 | + : 'Printar abertura de uma seção.' | |
633 | + | |
634 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
635 | + return 0 | |
636 | + fi | |
637 | + TITLE_P=$1 | |
638 | + echo "> ------------------------------------------------" | |
639 | + if [ -n "$TITLE_P" ] ; then | |
640 | + echo "$TITLE_P" | |
641 | + f_div_section | |
642 | + echo | |
643 | + fi | |
644 | +} | |
645 | + | |
646 | +f_close_section() { | |
647 | + : 'Printar fechamento de uma seção.' | |
648 | + | |
649 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
650 | + return 0 | |
651 | + fi | |
652 | + echo "< ------------------------------------------------" | |
653 | + echo | |
654 | +} | |
655 | + | |
656 | +f_div_section() { | |
657 | + : 'Printar divisão em uma seção.' | |
658 | + | |
659 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
660 | + return 0 | |
661 | + fi | |
662 | + echo "----------------------------------" | |
663 | +} | |
664 | + | |
665 | +f_sub_section() { | |
666 | + : 'Printar uma subseção. | |
667 | + | |
668 | + Args: | |
669 | + TITLE_P (str): Título da subseção. | |
670 | + TEXT_P (str): Texto da subseção. | |
671 | + ' | |
672 | + | |
673 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
674 | + return 0 | |
675 | + fi | |
676 | + TITLE_P=$1 | |
677 | + TEXT_P=$2 | |
678 | + echo "> $TITLE_P" | f_indent 2 | |
679 | + echo | |
680 | + echo "$TEXT_P" | f_indent 4 | |
681 | + echo | |
682 | +} | |
683 | + | |
684 | +# < -------------------------------------------------------------------------- | |
685 | + | |
686 | +# > -------------------------------------------------------------------------- | |
687 | +# APRESENTAÇÃO! | |
688 | +# -------------------------------------- | |
689 | + | |
690 | +f_begin() { | |
691 | + : 'Printar uma abertura/apresentação para o instalador do produto. | |
692 | + | |
693 | + Usar no início da instalação. | |
694 | + | |
695 | + Args: | |
696 | + TITLE_P (str): Título. | |
697 | + VERSION_P (str): Versão do produto. | |
698 | + ABOUT_P (str): Sobre o produto. | |
699 | + WARNINGS_P (str): Avisos antes de continuar. | |
700 | + COMPANY_P (str): Informações sobre a empresa. | |
701 | + ' | |
702 | + | |
703 | + clear | |
704 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
705 | + return 0 | |
706 | + fi | |
707 | + TITLE_P=$1 | |
708 | + VERSION_P=$2 | |
709 | + ABOUT_P=$3 | |
710 | + WARNINGS_P=$4 | |
711 | + COMPANY_P=$5 | |
712 | + f_open_section "$TITLE_P ($VERSION_P)" | |
713 | + f_sub_section "ABOUT:" "$ABOUT_P" | |
714 | + f_sub_section "WARNINGS:" "$WARNINGS_P" | |
715 | + f_div_section | |
716 | + echo "$COMPANY_P" | |
717 | + f_close_section | |
718 | + f_enter_to_cont | |
719 | + clear | |
720 | +} | |
721 | + | |
722 | +f_end() { | |
723 | + : 'Printar uma fechamento/encerramento para o instalador do produto. | |
724 | + | |
725 | + Usar no final da instalação. | |
726 | + | |
727 | + Args: | |
728 | + TITLE_P (str): Título. | |
729 | + USEFUL_INFO_P (str): Informações úteis (uso básico etc...). | |
730 | + ' | |
731 | + | |
732 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
733 | + return 0 | |
734 | + fi | |
735 | + TITLE_P=$1 | |
736 | + USEFUL_INFO_P=$2 | |
737 | + f_open_section "$TITLE_P" | |
738 | + f_sub_section "USEFUL INFORMATION:" "$USEFUL_INFO_P" | |
739 | + f_close_section | |
740 | +} | |
741 | + | |
742 | +f_terms_licen() { | |
743 | + : 'Printar os termos de licença/uso do produto. | |
744 | + | |
745 | + Pede que o usuário concorde com os termos. | |
746 | + | |
747 | + Args: | |
748 | + TERMS_LICEN_P (str): Termos de licença/uso do produto. | |
749 | + ' | |
750 | + | |
751 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
752 | + return 0 | |
753 | + fi | |
754 | + TERMS_LICEN_P=$1 | |
755 | + f_open_section "LICENSE/TERMS:" | |
756 | + echo "$TERMS_LICEN_P" | f_indent 2 | |
757 | + echo | |
758 | + f_div_section | |
759 | + TITLE_F="BY ANSWERING YES (y) YOU WILL AGREE WITH TERMS AND CONDITIONS "\ | |
760 | +"PRESENTED! PROCEED?" | |
761 | + f_yes_no "$TITLE_F" | |
762 | + TITLE_F="" | |
763 | + f_close_section | |
764 | + sleep 1 | |
765 | + if [ ${YES_NO_R} -eq 0 ] ; then | |
766 | + exit 0 | |
767 | + fi | |
768 | + clear | |
769 | +} | |
770 | + | |
771 | +f_instruct() { | |
772 | + : 'Printar instruções sobre o produto. | |
773 | + | |
774 | + Args: | |
775 | + INSTRUCT_P (str): Instruções sobre o produto. | |
776 | + ' | |
777 | + | |
778 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
779 | + return 0 | |
780 | + fi | |
781 | + INSTRUCT_P=$1 | |
782 | + f_open_section "INSTRUCTIONS:" | |
783 | + echo "$INSTRUCT_P" | f_indent 2 | |
784 | + echo | |
785 | + f_close_section | |
786 | + f_enter_to_cont | |
787 | + clear | |
788 | +} | |
789 | + | |
790 | +# < -------------------------------------------------------------------------- | |
791 | + | |
792 | +# > -------------------------------------------------------------------------- | |
793 | +# ESQUEMAS CONDICIONAIS! | |
794 | +# -------------------------------------- | |
795 | + | |
796 | +YES_NO_R=0 | |
797 | +f_yes_no() { | |
798 | + : 'Questiona ao usuário "yes" ou "no" sobre determinado algo. | |
799 | + | |
800 | + Args: | |
801 | + QUESTION_P (str): Questionamento a ser feito. | |
802 | + | |
803 | + Returns: | |
804 | + YES_NO_R (int): 1 - Yes; 0 - No. | |
805 | + ' | |
806 | + | |
807 | + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then | |
808 | + return 0 | |
809 | + fi | |
810 | + QUESTION_P=$1 | |
811 | + YES_NO_R=0 | |
812 | + read -r -p "$QUESTION_P (y/n) " RESP_V | |
813 | + if [[ $RESP_V =~ ^([sS]|[yY])$ ]] ; then | |
814 | + YES_NO_R=1 | |
815 | + elif [[ $RESP_V =~ ^([nN])$ ]] ; then | |
816 | + echo "NO!" | |
817 | + YES_NO_R=0 | |
818 | + else | |
819 | + f_yes_no "$QUESTION_P" | |
820 | + fi | |
821 | +} | |
822 | + | |
823 | +# < -------------------------------------------------------------------------- | ... | ... |
1 | +++ a/install.sh | |
... | ... | @@ -0,0 +1,859 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +# NOTE: Evita problemas com caminhos relativos! By Questor | |
4 | +SCRIPTDIR_V="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
5 | +. $SCRIPTDIR_V/ez_i.sh | |
6 | + | |
7 | +# > -------------------------------------------------------------------------- | |
8 | +# INÍCIO! | |
9 | +# -------------------------------------- | |
10 | + | |
11 | +read -d '' TITLE_F <<"EOF" | |
12 | +LBG - LBGenerator Installer | |
13 | +EOF | |
14 | + | |
15 | +read -d '' VERSION_F <<"EOF" | |
16 | +0.6.2.0 | |
17 | +EOF | |
18 | + | |
19 | +read -d '' ABOUT_F <<"EOF" | |
20 | +This script will install LBGenerator the LightBase data specification and model! | |
21 | + | |
22 | +Have fun! =D | |
23 | +EOF | |
24 | + | |
25 | +read -d '' WARNINGS_F <<"EOF" | |
26 | +- Installer designed for CentOS 6 AMD64/RHEL 6 AMD64! | |
27 | + | |
28 | +- We RECOMMEND you... | |
29 | + Install all the components (answer yes to everything). Except | |
30 | + contrary guidance! | |
31 | + Check for previous installations! If there is previous | |
32 | + installations consider this variant in the process! | |
33 | +- We WARNING you... | |
34 | + USE AT YOUR OWN RISK: WE ARE NOT RESPONSIBLE FOR ANY DAMAGE TO | |
35 | +YOURSELF, HARDWARE, OR CO-WORKERS. EXCEPT IN CASES WHERE THERE ARE | |
36 | +SIGNED CONTRACT THAT REGULATES THIS! | |
37 | +EOF | |
38 | + | |
39 | +read -d '' COMPANY_F <<"EOF" | |
40 | +BR Light LTDA - LightBase Consulting in Public Software/LightBase Consultoria em Software Público | |
41 | +Free Software + Our Ideas = Best Solution!/Software Livre + Nossas Idéias = Melhor Solução! | |
42 | ++55-61-3347-1949 - http://www.LightBase.com.br - Brasil-DF | |
43 | +EOF | |
44 | + | |
45 | +f_begin "$TITLE_F" "$VERSION_F" "$ABOUT_F" "$WARNINGS_F" "$COMPANY_F" | |
46 | +ABOUT_F="" | |
47 | +WARNINGS_F="" | |
48 | + | |
49 | +# < -------------------------------------------------------------------------- | |
50 | + | |
51 | +# > -------------------------------------------------------------------------- | |
52 | +# TERMOS E LICENÇA! | |
53 | +# -------------------------------------- | |
54 | + | |
55 | +read -d '' TERMS_LICEN_F <<"EOF" | |
56 | +BY USING THIS INSTALLER YOU ARE AGREEING TO THE TERMS OF USE OF ALL | |
57 | +INVOLVED SOFTWARE! | |
58 | +EOF | |
59 | + | |
60 | +f_terms_licen "$TERMS_LICEN_F" | |
61 | +TERMS_LICEN_F="" | |
62 | + | |
63 | +# < -------------------------------------------------------------------------- | |
64 | + | |
65 | +# > -------------------------------------------------------------------------- | |
66 | +# INTRUÇÕES! | |
67 | +# -------------------------------------- | |
68 | + | |
69 | +read -d '' INSTRUCT_F <<"EOF" | |
70 | +- To run this script YOU NEED to be root! | |
71 | + | |
72 | +- TO CANCEL installation at any time use Ctrl+c! | |
73 | +EOF | |
74 | + | |
75 | +f_instruct "$INSTRUCT_F" | |
76 | +INSTRUCT_F="" | |
77 | + | |
78 | +# < -------------------------------------------------------------------------- | |
79 | + | |
80 | +# > ----------------------------------------- | |
81 | +# Dá ao usuário mais avançado a possibilideade de usar o instalador | |
82 | +# simplificado! | |
83 | + | |
84 | +# NOTE: É possível forçar o processo de instalção simplificado setando | |
85 | +# "SIMPLE_INST" com 1! By Questor | |
86 | +SIMPLE_INST=0 | |
87 | +if [ ${SIMPLE_INST} -eq 0 ] ; then | |
88 | + f_open_section | |
89 | + f_yes_no "Use simple install (using a default value for most of the options)?" | |
90 | + if [ ${YES_NO_R} -eq 1 ] ; then | |
91 | + | |
92 | + # NOTE: Essa variável serve apenas para "preservar" o valor | |
93 | + # setado pelo usuário sendo somente "leitura". A variável a | |
94 | + # ser usada nas regras deve ser "EZ_I_SKIP_ON_V" (ez_i.sh)! Essa | |
95 | + # estratégia serve para mudarmos o comportamento do "ez_i.sh" | |
96 | + # de acordo com as circunstâncias! By Questor | |
97 | + SIMPLE_INST=1 | |
98 | + | |
99 | + # NOTE: Essa variável é para consumo do "ez_i.sh", para que ele | |
100 | + # não execute algumas funções e simplifique o processo de | |
101 | + # instalação! By Questor | |
102 | + EZ_I_SKIP_ON_V=1 | |
103 | + fi | |
104 | + f_close_section | |
105 | + sleep 1 | |
106 | +fi | |
107 | + | |
108 | +# < ----------------------------------------- | |
109 | + | |
110 | +# > ----------------------------------------- | |
111 | +# Garantir o encodamento correto para evitar problemas de | |
112 | +# compatibilidade! | |
113 | + | |
114 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
115 | +f_open_section | |
116 | +read -d '' TITLE_F <<"EOF" | |
117 | +Set terminal encode? (recommended for Windows terminal clients) | |
118 | +EOF | |
119 | + | |
120 | +f_yes_no "$TITLE_F" | |
121 | +TITLE_F="" | |
122 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
123 | + export LANG=pt_BR.utf8 | |
124 | +fi | |
125 | +f_close_section | |
126 | + | |
127 | +# < ----------------------------------------- | |
128 | + | |
129 | +# > ----------------------------------------- | |
130 | +# Desabilita o SElinux! | |
131 | + | |
132 | +EZ_I_SKIP_ON_V=0 | |
133 | +f_open_section | |
134 | +read -d '' TITLE_F <<"EOF" | |
135 | +Disable SElinux (use "y" if you never did it)? | |
136 | +EOF | |
137 | + | |
138 | +f_yes_no "$TITLE_F" | |
139 | +TITLE_F="" | |
140 | +if [ ${YES_NO_R} -eq 1 ] ; then | |
141 | + setenforce 0 | |
142 | + | |
143 | + # NOTE: As condições abaixo visam evitar que o arquivo seja | |
144 | + # desnecessariamente e erroneamente modificado! By Questor | |
145 | + EZ_I_SKIP_ON_V=$SIMPLE_INST | |
146 | + f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!" | |
147 | + EZ_I_SKIP_ON_V=0 | |
148 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
149 | + f_fl_cont_str "SELINUX=disabled" "/etc/sysconfig/selinux" | |
150 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
151 | + f_ez_sed "SELINUX=enforcing" "# SELINUX=enforcing\nSELINUX=disabled" "/etc/sysconfig/selinux" | |
152 | + fi | |
153 | + fi | |
154 | +fi | |
155 | +f_close_section | |
156 | + | |
157 | +# < ----------------------------------------- | |
158 | + | |
159 | +# > ----------------------------------------- | |
160 | +# Instala os componentes de base usados pela especificação LightBase! | |
161 | + | |
162 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
163 | +f_open_section | |
164 | +read -d '' TITLE_F <<"EOF" | |
165 | +Install base components? | |
166 | +EOF | |
167 | + | |
168 | +f_yes_no "$TITLE_F" | |
169 | +TITLE_F="" | |
170 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
171 | + f_pack_is_inst "gcc-c++" "yum" "\"gcc-c++\" already installed!" | |
172 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
173 | + yum -y install gcc-c++ | |
174 | + fi | |
175 | + f_pack_is_inst "zlib-devel" "yum" "\"zlib-devel\" already installed!" | |
176 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
177 | + yum -y install zlib-devel | |
178 | + fi | |
179 | + f_pack_is_inst "openssl-devel" "yum" "\"openssl-devel\" already installed!" | |
180 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
181 | + yum -y install openssl-devel | |
182 | + fi | |
183 | + f_pack_is_inst "postgresql-devel" "yum" "\"postgresql-devel\" already installed!" | |
184 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
185 | + yum -y install postgresql-devel | |
186 | + fi | |
187 | + f_pack_is_inst "git" "yum" "\"git\" already installed!" | |
188 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
189 | + yum -y install git | |
190 | + fi | |
191 | +fi | |
192 | +f_close_section | |
193 | + | |
194 | +# < ----------------------------------------- | |
195 | + | |
196 | +BASE_INST_DIR_V="/usr/local/lb" | |
197 | +# > ----------------------------------------- | |
198 | +# Criar o diretório base da instalação! | |
199 | + | |
200 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
201 | +f_open_section | |
202 | +QUESTION_F="Insert where the base installation directory (\"lb\") will be created (don't use \"/\" at the end). | |
203 | +Use empty for \"/usr/local\"!" | |
204 | + | |
205 | +f_get_usr_input "$QUESTION_F" 1 | |
206 | +QUESTION_F="" | |
207 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ -z "$GET_USR_INPUT_R" ] ; then | |
208 | + f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!" | |
209 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then | |
210 | + mkdir -p "$BASE_INST_DIR_V" | |
211 | + fi | |
212 | +else | |
213 | + BASE_INST_DIR_V="$GET_USR_INPUT_R/lb" | |
214 | + f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!" | |
215 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then | |
216 | + mkdir -p "$BASE_INST_DIR_V" | |
217 | + fi | |
218 | +fi | |
219 | +f_close_section | |
220 | + | |
221 | +# < ----------------------------------------- | |
222 | + | |
223 | +# > ----------------------------------------- | |
224 | +# Instalar o python3.2! | |
225 | + | |
226 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
227 | +f_open_section | |
228 | +read -d '' TITLE_F <<"EOF" | |
229 | +Install python3.2? | |
230 | +EOF | |
231 | + | |
232 | +f_yes_no "$TITLE_F" | |
233 | +TITLE_F="" | |
234 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
235 | + f_chk_by_path_hlp "$BASE_INST_DIR_V/py32" "d" "python3.2 already installed in \"$BASE_INST_DIR_V/py32\"!" | |
236 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then | |
237 | + cd "$SCRIPTDIR_V" | |
238 | + cd ./other-srcs-n-apps | |
239 | + tar -zxvf Python-3.2.2.tar.gz | |
240 | + cd ./Python-3.2.2 | |
241 | + eval "./configure --prefix=$BASE_INST_DIR_V/py32/ --with-threads --enable-shared LDFLAGS=-Wl,-rpath=$BASE_INST_DIR_V/py32/lib/" | |
242 | + make && make install | |
243 | + cd .. | |
244 | + rm -rf ./Python-3.2.2 | |
245 | + f_enter_to_cont "python3.2 installed in \"$BASE_INST_DIR_V/py32\"!" | |
246 | + fi | |
247 | +fi | |
248 | +f_close_section | |
249 | + | |
250 | +# < ----------------------------------------- | |
251 | + | |
252 | +# > ----------------------------------------- | |
253 | +# Instalar o virtualenv-1.11.6 no python3.2! | |
254 | + | |
255 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
256 | +f_open_section | |
257 | +read -d '' TITLE_F <<"EOF" | |
258 | +Install virtualenv-1.11.6 on python3.2? | |
259 | +EOF | |
260 | + | |
261 | +f_yes_no "$TITLE_F" | |
262 | +TITLE_F="" | |
263 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
264 | + f_chk_by_path_hlp "$BASE_INST_DIR_V/py32/bin/virtualenv-3.2" "f" "virtualenv-1.11.6 already installed in python3.2 (\"$BASE_INST_DIR_V/py32\")!" | |
265 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then | |
266 | + cd "$SCRIPTDIR_V" | |
267 | + cd ./other-srcs-n-apps | |
268 | + tar -zxvf virtualenv-1.11.6.tar.gz | |
269 | + cd virtualenv-1.11.6 | |
270 | + $BASE_INST_DIR_V/py32/bin/python3.2 setup.py install | |
271 | + cd .. | |
272 | + rm -rf virtualenv-1.11.6 | |
273 | + fi | |
274 | +fi | |
275 | +f_close_section | |
276 | + | |
277 | +# < ----------------------------------------- | |
278 | + | |
279 | +# > ----------------------------------------- | |
280 | +# Criar o ambiente virtual (python3.2)! | |
281 | + | |
282 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
283 | +f_open_section | |
284 | +f_enter_to_cont "Create the virtual environment (python3.2)!" | |
285 | + | |
286 | +f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32" "d" "Virtual environment (python3.2) already created in \"$BASE_INST_DIR_V/ve32\"!" | |
287 | +if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then | |
288 | + cd "$BASE_INST_DIR_V" | |
289 | + $BASE_INST_DIR_V/py32/bin/virtualenv-3.2 ve32 | |
290 | + mkdir "$BASE_INST_DIR_V/ve32/src" | |
291 | + f_enter_to_cont "Virtual environment created in \"$BASE_INST_DIR_V/ve32\"!" | |
292 | +fi | |
293 | +f_close_section | |
294 | + | |
295 | +# < ----------------------------------------- | |
296 | + | |
297 | +# > ----------------------------------------- | |
298 | +# Instalar o Apache (httpd)! | |
299 | + | |
300 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
301 | +f_open_section | |
302 | +read -d '' TITLE_F <<"EOF" | |
303 | +Install Apache (httpd)? | |
304 | +EOF | |
305 | + | |
306 | +f_yes_no "$TITLE_F" | |
307 | +TITLE_F="" | |
308 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
309 | + f_pack_is_inst "httpd-devel" "yum" "Apache (httpd) already installed!" | |
310 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
311 | + yum -y install httpd-devel httpd | |
312 | + chkconfig httpd on | |
313 | + chown -R apache /var/www | |
314 | + chmod -R 755 /var/www | |
315 | + fi | |
316 | +fi | |
317 | +f_close_section | |
318 | + | |
319 | +# < ----------------------------------------- | |
320 | + | |
321 | +# > ----------------------------------------- | |
322 | +# Abrir o firewall para o Apache (httpd)! | |
323 | + | |
324 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
325 | +f_open_section | |
326 | +read -d '' TITLE_F <<"EOF" | |
327 | +Open firewall for Apache (httpd) (TCP 80)? | |
328 | +EOF | |
329 | + | |
330 | +f_yes_no "$TITLE_F" | |
331 | +TITLE_F="" | |
332 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
333 | + f_chk_iptables 80 "Port 80 is already open!" 0 "ACCEPT" "tcp" "NEW" | |
334 | + if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then | |
335 | + iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT | |
336 | + service iptables save | |
337 | + service iptables restart | |
338 | + fi | |
339 | +fi | |
340 | +f_close_section | |
341 | + | |
342 | +# < ----------------------------------------- | |
343 | + | |
344 | +# > ----------------------------------------- | |
345 | +# Instalar o mod_wsgi-4.3.2! | |
346 | + | |
347 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
348 | +f_open_section | |
349 | +read -d '' TITLE_F <<"EOF" | |
350 | +Install mod_wsgi-4.3.2? | |
351 | +EOF | |
352 | + | |
353 | +f_yes_no "$TITLE_F" | |
354 | +TITLE_F="" | |
355 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
356 | + cd "$SCRIPTDIR_V" | |
357 | + cd ./other-srcs-n-apps | |
358 | + | |
359 | + f_fl_cont_str "$BASE_INST_DIR_V/py32/lib" "/etc/ld.so.conf" "The file \"/etc/ld.so.conf\" probably has already been changed! Check it!" | |
360 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
361 | + f_ez_sed "include ld.so.conf.d/*.conf" "include ld.so.conf.d/*.conf\n$BASE_INST_DIR_V/py32/lib" "/etc/ld.so.conf" | |
362 | + fi | |
363 | + | |
364 | + UP_MOD_WSGI=1 | |
365 | + f_chk_by_path_hlp "/usr/lib64/httpd/modules/mod_wsgi.so" "f" "mod_wsgi already installed in \"/usr/lib64/httpd/modules/mod_wsgi.so\"!" | |
366 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then | |
367 | + if [ ${EZ_I_SKIP_ON_V} -eq 0 ] ; then | |
368 | + TITLE_F="Update/reinstall mod_wsgi? (\"y\" recommended)" | |
369 | + f_div_section | |
370 | + f_yes_no "$TITLE_F" | |
371 | + f_div_section | |
372 | + TITLE_F="" | |
373 | + UP_MOD_WSGI=$YES_NO_R | |
374 | + if [ ${UP_MOD_WSGI} -eq 1 ] ; then | |
375 | + rm -rf "/usr/lib64/httpd/modules/mod_wsgi.so" | |
376 | + fi | |
377 | + fi | |
378 | + fi | |
379 | + if [ ${UP_MOD_WSGI} -eq 1 ] ; then | |
380 | + ldconfig | |
381 | + tar -zxvf ./mod_wsgi-4.3.2.tar.gz | |
382 | + cd ./mod_wsgi-4.3.2 | |
383 | + eval "./configure --with-python=$BASE_INST_DIR_V/py32/bin/python3.2" | |
384 | + make && make install | |
385 | + cd .. | |
386 | + rm -rf ./mod_wsgi-4.3.2 | |
387 | + fi | |
388 | +fi | |
389 | +f_close_section | |
390 | + | |
391 | +# < ----------------------------------------- | |
392 | + | |
393 | +# > ----------------------------------------- | |
394 | +# Instalar o ElasticSearch! | |
395 | + | |
396 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
397 | +f_open_section | |
398 | +read -d '' TITLE_F <<"EOF" | |
399 | +Install ElasticSearch? | |
400 | +EOF | |
401 | + | |
402 | +f_yes_no "$TITLE_F" | |
403 | +TITLE_F="" | |
404 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
405 | + f_pack_is_inst "elasticsearch.noarch" "yum" "ElasticSearch already installed!" | |
406 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
407 | + f_pack_is_inst "java-1.7.0-openjdk" "yum" "java-1.7.0-openjdk already installed!" | |
408 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
409 | + yum -y install java-1.7.0-openjdk | |
410 | + fi | |
411 | + cd "$SCRIPTDIR_V" | |
412 | + cd ./other-srcs-n-apps | |
413 | + rpm -Uvh elasticsearch-1.1.1.noarch.rpm | |
414 | + /sbin/chkconfig --add elasticsearch | |
415 | + f_fl_cont_str "cluster.name: lb" "/etc/elasticsearch/elasticsearch.yml" "The file \"/etc/elasticsearch/elasticsearch.yml\" probably has already been changed! Check it!" | |
416 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
417 | + f_ez_sed "# cluster.name: elasticsearch" "# cluster.name: elasticsearch\ncluster.name: lb" "/etc/elasticsearch/elasticsearch.yml" | |
418 | + fi | |
419 | + service elasticsearch start | |
420 | + fi | |
421 | +fi | |
422 | +f_close_section | |
423 | + | |
424 | +# < ----------------------------------------- | |
425 | + | |
426 | +# > ----------------------------------------- | |
427 | +# Abrir o firewall para o ElasticSearch! | |
428 | + | |
429 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
430 | +f_open_section | |
431 | +read -d '' TITLE_F <<"EOF" | |
432 | +Open firewall for ElasticSearch (TCP 9200)? | |
433 | +EOF | |
434 | + | |
435 | +f_yes_no "$TITLE_F" | |
436 | +TITLE_F="" | |
437 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
438 | + f_chk_iptables 9200 "Port 9200 is already open!" 0 "ACCEPT" "tcp" "NEW" | |
439 | + if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then | |
440 | + iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT | |
441 | + service iptables save | |
442 | + service iptables restart | |
443 | + fi | |
444 | +fi | |
445 | +f_close_section | |
446 | + | |
447 | +# < ----------------------------------------- | |
448 | + | |
449 | +# > ----------------------------------------- | |
450 | +# Instalar o postgres 9.4! | |
451 | + | |
452 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
453 | +f_open_section | |
454 | +read -d '' TITLE_F <<"EOF" | |
455 | +Install postgres 9.4? | |
456 | +EOF | |
457 | + | |
458 | +f_yes_no "$TITLE_F" | |
459 | +TITLE_F="" | |
460 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
461 | + cd "$SCRIPTDIR_V" | |
462 | + cd ./other-srcs-n-apps | |
463 | + f_pack_is_inst "pgdg-centos94-9.4-1.noarch" "yum" "postgres 9.4 already installed!" | |
464 | + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then | |
465 | + yum -y localinstall pgdg-centos94-9.4-1.noarch.rpm | |
466 | + yum -y install postgresql94-server | |
467 | + service postgresql-9.4 initdb | |
468 | + chkconfig postgresql-9.4 on | |
469 | + service postgresql-9.4 start | |
470 | + fi | |
471 | +fi | |
472 | +f_close_section | |
473 | + | |
474 | +# < ----------------------------------------- | |
475 | + | |
476 | +# > ----------------------------------------- | |
477 | +# Configurar o postgres 9.4! | |
478 | + | |
479 | +CONF_PG=0 | |
480 | +EZ_I_SKIP_ON_V=0 | |
481 | +f_open_section | |
482 | +TITLE_F="Configure postgres 9.4 (use \"y\" if you never did it)?" | |
483 | +f_yes_no "$TITLE_F" | |
484 | +TITLE_F="" | |
485 | +PG_USER_F="lbu" | |
486 | +PG_PWD_F="lbu" | |
487 | +PG_EXT_ACS_F="" | |
488 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
489 | + | |
490 | + EZ_I_SKIP_ON_V=$SIMPLE_INST | |
491 | + | |
492 | + f_div_section | |
493 | + | |
494 | + QUESTION_F="Enter the postgres 9.4 user for lightbase (LBG). | |
495 | +Use empty for \"$PG_USER_F\"!" | |
496 | + | |
497 | + f_get_usr_input "$QUESTION_F" 1 | |
498 | + QUESTION_F="" | |
499 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
500 | + PG_USER_F=$GET_USR_INPUT_R | |
501 | + fi | |
502 | + | |
503 | + f_div_section | |
504 | + | |
505 | + QUESTION_F="Enter the postgres 9.4 password for \"$PG_USER_F\". | |
506 | +Use empty for \"$PG_PWD_F\"!" | |
507 | + | |
508 | + f_get_usr_input "$QUESTION_F" 1 | |
509 | + QUESTION_F="" | |
510 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
511 | + PG_PWD_F=$GET_USR_INPUT_R | |
512 | + fi | |
513 | + | |
514 | + f_div_section | |
515 | + | |
516 | + QUESTION_F="Enter one ip or ip range for external access. | |
517 | +e.g. \"172.20.143.89/32\" for a single host or \"172.20.143.0/24\" for a small network or \"10.6.0.0/16\" for a larger one! | |
518 | +Use empty for local access only!" | |
519 | + | |
520 | + f_get_usr_input "$QUESTION_F" 1 | |
521 | + QUESTION_F="" | |
522 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
523 | + PG_EXT_ACS_F=$GET_USR_INPUT_R | |
524 | + fi | |
525 | + EZ_I_SKIP_ON_V=0 | |
526 | + | |
527 | + f_is_not_running "postgres" "ERROR! \"postgres\" service not running!" | |
528 | + if [ ${F_IS_NOT_RUNNING_R} -eq 0 ] ; then | |
529 | + cd /tmp | |
530 | + f_get_stderr_stdout "sudo -u postgres psql -tAc \"SELECT * FROM pg_roles WHERE rolname='$PG_USER_F';\"" | |
531 | + if [[ $F_GET_STDOUT_R == *"$PG_USER_F|"* ]]; then | |
532 | + # NOTE: | |
533 | + # rolname| | |
534 | + # rolsuper| | |
535 | + # rolinherit| | |
536 | + # rolcreaterole| | |
537 | + # rolcreatedb| | |
538 | + # rolcatupdate| | |
539 | + # rolcanlogin| | |
540 | + # rolconnlimit| | |
541 | + # rolpassword| | |
542 | + # rolvaliduntil| | |
543 | + # rolconfig| | |
544 | + # oid | |
545 | + # ! By Questor | |
546 | + if [[ $F_GET_STDOUT_R != *"$PG_USER_F|t|t|t|t|t|t|f|-1|"* ]]; then | |
547 | + f_div_section | |
548 | + echo "The user \"$PG_USER_F\" already created, but something is apparently wrong with his roles. The expected roles are \"lbu|f|t|t|t|t|t|f|-1|...\"! DETAILS: \"$F_GET_STDOUT_R\"." | |
549 | + f_div_section | |
550 | + f_continue | |
551 | + else | |
552 | + EZ_I_SKIP_ON_V=$SIMPLE_INST | |
553 | + f_enter_to_cont "The user \"$PG_USER_F\" already created and his roles are correct!" | |
554 | + EZ_I_SKIP_ON_V=0 | |
555 | + fi | |
556 | + else | |
557 | + if [[ $F_GET_STDERR_R == "" ]]; then | |
558 | + sudo -u postgres psql -c "CREATE USER $PG_USER_F INHERIT SUPERUSER CREATEROLE CREATEDB;" | |
559 | + sudo -u postgres psql -c "ALTER USER $PG_USER_F PASSWORD '$PG_PWD_F';" | |
560 | + else | |
561 | + f_enter_to_cont "An error occurred when creating \"$PG_USER_F\" user permissions! ERROR: \"$F_GET_STDERR_R\"." | |
562 | + f_error_exit | |
563 | + fi | |
564 | + fi | |
565 | + cd - >/dev/null | |
566 | + else | |
567 | + f_error_exit | |
568 | + fi | |
569 | + | |
570 | + EZ_I_SKIP_ON_V=$SIMPLE_INST | |
571 | + if [ -n "$PG_EXT_ACS_F" ] ; then | |
572 | + f_fl_cont_str "host all all $PG_EXT_ACS_F trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" probably has already been changed for external access! Check it!" | |
573 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
574 | + f_ez_sed "# IPv4 local connections:" "# IPv4 local connections:\nhost all all $PG_EXT_ACS_F trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" | |
575 | + fi | |
576 | + fi | |
577 | + | |
578 | + f_fl_cont_str "host all all 127.0.0.1/32 trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" probably has already been changed for local access! Check it!" | |
579 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
580 | + f_ez_sed "# IPv4 local connections:" "# IPv4 local connections:\nhost all all 127.0.0.1/32 trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" | |
581 | + fi | |
582 | + | |
583 | + f_fl_cont_str "listen_addresses = '*'" "/var/lib/pgsql/9.4/data/postgresql.conf" "The file \"/var/lib/pgsql/9.4/data/postgresql.conf\" probably has already been changed! Check it!" | |
584 | + if [ ${FL_CONT_STR_R} -eq 0 ] ; then | |
585 | + f_ez_sed "# - Connection Settings -" "# - Connection Settings -\n\nlisten_addresses = '*'" "/var/lib/pgsql/9.4/data/postgresql.conf" | |
586 | + fi | |
587 | + | |
588 | + service postgresql-9.4 restart | |
589 | + f_enter_to_cont "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" has settings for postgres 9.4! Check it for more details!" | |
590 | + EZ_I_SKIP_ON_V=0 | |
591 | + CONF_PG=1 | |
592 | +else | |
593 | + f_enter_to_cont "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" has settings for postgres 9.4! Check it!" | |
594 | +fi | |
595 | +f_close_section | |
596 | + | |
597 | +# < ----------------------------------------- | |
598 | + | |
599 | +# > ----------------------------------------- | |
600 | +# Abrir o firewall para o postgres 9.4! | |
601 | + | |
602 | +EZ_I_SKIP_ON_V=0 | |
603 | +f_open_section | |
604 | +read -d '' TITLE_F <<"EOF" | |
605 | +Open firewall for postgres 9.4 (TCP 5432)? | |
606 | +EOF | |
607 | + | |
608 | +f_yes_no "$TITLE_F" | |
609 | +TITLE_F="" | |
610 | +if [ ${YES_NO_R} -eq 1 ] ; then | |
611 | + f_chk_iptables 5432 "Port 5432 is already open!" 0 "ACCEPT" "tcp" | |
612 | + if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then | |
613 | + iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT | |
614 | + service iptables save | |
615 | + service iptables restart | |
616 | + fi | |
617 | +fi | |
618 | +f_close_section | |
619 | + | |
620 | +# < ----------------------------------------- | |
621 | + | |
622 | +# > ----------------------------------------- | |
623 | +# Criar as estruturas de dados básicas do LB no postgres 9.4! | |
624 | + | |
625 | +CREATE_LB_DT=0 | |
626 | +EZ_I_SKIP_ON_V=0 | |
627 | +f_open_section | |
628 | +TITLE_F="Create the basic LightBase (LBG) data structures in postgres 9.4 (use \"y\" if you never did it)?" | |
629 | +f_yes_no "$TITLE_F" | |
630 | +TITLE_F="" | |
631 | +PG_DB_F="lb" | |
632 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
633 | + | |
634 | + EZ_I_SKIP_ON_V=$SIMPLE_INST | |
635 | + QUESTION_F="Enter the postgres 9.4 database name for LightBase (LBG). | |
636 | +Use empty for \"$PG_DB_F\" (recommended)!" | |
637 | + | |
638 | + f_get_usr_input "$QUESTION_F" 1 | |
639 | + QUESTION_F="" | |
640 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
641 | + PG_DB_F=$GET_USR_INPUT_R | |
642 | + fi | |
643 | + EZ_I_SKIP_ON_V=0 | |
644 | + f_is_not_running "postgres" "ERROR! \"postgres\" service not running!" | |
645 | + if [ ${F_IS_NOT_RUNNING_R} -eq 0 ] ; then | |
646 | + cd /tmp | |
647 | + f_get_stderr_stdout "sudo -u postgres psql -c \"CREATE DATABASE $PG_DB_F;\"" | |
648 | + if [[ $F_GET_STDERR_R != "" ]]; then | |
649 | + if [[ $F_GET_STDERR_R == *" already exists"* ]]; then | |
650 | + EZ_I_SKIP_ON_V=$SIMPLE_INST | |
651 | + f_enter_to_cont "The database \"$PG_DB_F\" already created!" | |
652 | + EZ_I_SKIP_ON_V=0 | |
653 | + else | |
654 | + f_div_section | |
655 | + echo "An error occurred when creating \"$PG_DB_F\" database! ERROR: \"$F_GET_STDERR_R\"." | |
656 | + f_div_section | |
657 | + f_error_exit | |
658 | + fi | |
659 | + else | |
660 | + cd "$SCRIPTDIR_V" | |
661 | + cp ./lbn-basic-dt-strt/lbn_basic_dt_strt.sql /tmp | |
662 | + cd /tmp | |
663 | + chmod 700 lbn_basic_dt_strt.sql | |
664 | + chown postgres lbn_basic_dt_strt.sql | |
665 | + chown :postgres lbn_basic_dt_strt.sql | |
666 | + sudo -u postgres psql $PG_DB_F -f lbn_basic_dt_strt.sql | |
667 | + rm -f lbn_basic_dt_strt.sql | |
668 | + fi | |
669 | + else | |
670 | + f_error_exit | |
671 | + fi | |
672 | + CREATE_LB_DT=1 | |
673 | +else | |
674 | + f_enter_to_cont "The file \"./lbn-basic-dt-strt/lbn_basic_dt_strt.sql\" has the basic LightBase (LBG) data structures! Check it!" | |
675 | +fi | |
676 | +f_close_section | |
677 | + | |
678 | +# < ----------------------------------------- | |
679 | + | |
680 | +# > ----------------------------------------- | |
681 | +# Instalar as dependências python da LIB - liblightbase! | |
682 | + | |
683 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
684 | +cd "$SCRIPTDIR_V" | |
685 | +sh py-packs-liblightbase.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" | |
686 | + | |
687 | +# < ----------------------------------------- | |
688 | + | |
689 | +# > ----------------------------------------- | |
690 | +# Instalar a LIB - liblightbase! | |
691 | + | |
692 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
693 | +f_open_section | |
694 | +read -d '' TITLE_F <<"EOF" | |
695 | +Install the LIB - liblightbase? | |
696 | +EOF | |
697 | + | |
698 | +f_yes_no "$TITLE_F" | |
699 | +TITLE_F="" | |
700 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
701 | + f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32/src/liblightbase" "d" "\"liblightbase\" already installed in \"$BASE_INST_DIR_V/ve32/src\"!" | |
702 | + F_BAK_MD_R=1 | |
703 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then | |
704 | + f_ez_mv_bak "$BASE_INST_DIR_V/ve32/src/liblightbase" "Backup old version and update? (\"y\" recommended)" | |
705 | + fi | |
706 | + if [ ${F_BAK_MD_R} -eq 1 ] ; then | |
707 | + cd "$SCRIPTDIR_V" | |
708 | + tar -zxvf liblightbase.tar.gz | |
709 | + mv "$SCRIPTDIR_V/liblightbase" "$BASE_INST_DIR_V/ve32/src/" | |
710 | + cd "$BASE_INST_DIR_V/ve32/src/liblightbase" | |
711 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
712 | + fi | |
713 | +fi | |
714 | +f_close_section | |
715 | + | |
716 | +# < ----------------------------------------- | |
717 | + | |
718 | +# > ----------------------------------------- | |
719 | +# Instalar e configurar o LBG - LBGenerator! | |
720 | + | |
721 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
722 | +cd "$SCRIPTDIR_V" | |
723 | +sh py-packs-LBGenerator.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" | |
724 | + | |
725 | +# < ----------------------------------------- | |
726 | + | |
727 | +# > ----------------------------------------- | |
728 | +# Instalar o LBG - LBGenerator! | |
729 | + | |
730 | +EZ_I_SKIP_ON_V=$SIMPLE_INST | |
731 | +APP_URL_F="lbg" | |
732 | +f_open_section | |
733 | +read -d '' TITLE_F <<"EOF" | |
734 | +Install the LBG - LBGenerator? | |
735 | +EOF | |
736 | + | |
737 | +f_yes_no "$TITLE_F" | |
738 | +TITLE_F="" | |
739 | +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then | |
740 | + | |
741 | + f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32/src/LBGenerator" "d" "\"LBGenerator\" already installed in \"$BASE_INST_DIR_V/ve32/src\"!" | |
742 | + F_BAK_MD_R=1 | |
743 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then | |
744 | + f_ez_mv_bak "$BASE_INST_DIR_V/ve32/src/LBGenerator" "Backup old version and update? (\"y\" recommended)" | |
745 | + fi | |
746 | + if [ ${F_BAK_MD_R} -eq 1 ] ; then | |
747 | + cd "$SCRIPTDIR_V" | |
748 | + tar -zxvf LBGenerator.tar.gz | |
749 | + mv "$SCRIPTDIR_V/LBGenerator" "$BASE_INST_DIR_V/ve32/src/" | |
750 | + cd "$BASE_INST_DIR_V/ve32/src/LBGenerator" | |
751 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
752 | + | |
753 | + f_enter_to_cont "Configure httpd (Apache) for LBG - LBGenerator!" | |
754 | + | |
755 | + # NOTE: To debug! By Questor | |
756 | + # PG_USER_F="lbu" | |
757 | + # PG_PWD_F="lbu" | |
758 | + # PG_DB_F="lb" | |
759 | + PG_CFG_F="postgresql://$PG_USER_F:$PG_PWD_F@127.0.0.1/$PG_DB_F" | |
760 | + QUESTION_F="Enter the postgres 9.4 LBG configuration. | |
761 | +Use empty for \"$PG_CFG_F\"!" | |
762 | + | |
763 | + f_div_section | |
764 | + f_get_usr_input "$QUESTION_F" 1 | |
765 | + f_div_section | |
766 | + QUESTION_F="" | |
767 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
768 | + PG_CFG_F=$GET_USR_INPUT_R | |
769 | + fi | |
770 | + | |
771 | + QUESTION_F="Enter lightbase URL. | |
772 | +Use empty for \"$APP_URL_F\" (used like e.g. http://<ip_or_name>/$APP_URL_F)!" | |
773 | + f_div_section | |
774 | + f_get_usr_input "$QUESTION_F" 1 | |
775 | + f_div_section | |
776 | + QUESTION_F="" | |
777 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
778 | + APP_URL_F=$GET_USR_INPUT_R | |
779 | + fi | |
780 | + | |
781 | + eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi\"" | |
782 | + f_ez_sed "<VE32_PATH>" "$BASE_INST_DIR_V/ve32" "$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi" | |
783 | + | |
784 | + eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini\"" | |
785 | + f_ez_sed "<SQLALCHEMY_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1 | |
786 | + | |
787 | + f_chk_by_path_hlp "/etc/httpd/conf.d/lbg.conf" "f" "\"lbg.conf\" already created in \"/etc/httpd/conf.d/lbg.conf\"!" | |
788 | + F_BAK_MD_R=1 | |
789 | + if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then | |
790 | + f_ez_mv_bak "/etc/httpd/conf.d/lbg.conf" "Backup old version and update? (\"y\" recommended)" | |
791 | + fi | |
792 | + | |
793 | + if [ ${F_BAK_MD_R} -eq 1 ] ; then | |
794 | + eval "cp -f \"$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf.dist\" \"/etc/httpd/conf.d/lbg.conf\"" | |
795 | + f_ez_sed "<VE32_PATH>" "$BASE_INST_DIR_V/ve32" "/etc/httpd/conf.d/lbg.conf" 1 | |
796 | + f_ez_sed "<LBG_URL>" "$APP_URL_F" "/etc/httpd/conf.d/lbg.conf" 1 | |
797 | + fi | |
798 | + | |
799 | + eval "chown -R apache $BASE_INST_DIR_V" | |
800 | + eval "chmod -R 755 $BASE_INST_DIR_V" | |
801 | + | |
802 | + service httpd restart | |
803 | + fi | |
804 | +fi | |
805 | +f_close_section | |
806 | + | |
807 | +# < ----------------------------------------- | |
808 | + | |
809 | +# > -------------------------------------------------------------------------- | |
810 | +# FINAL! | |
811 | +# -------------------------------------- | |
812 | + | |
813 | +EZ_I_SKIP_ON_V=0 | |
814 | +read -d '' TITLE_F <<"EOF" | |
815 | +Installer finished! Thanks! | |
816 | +EOF | |
817 | + | |
818 | +# NOTE: A lógica imediatamente abaixo serve para os casos onde o | |
819 | +# usuário optou por instalação simplificada para que ele seja informado | |
820 | +# sobre quais foram as configurações de persistência setadas! By Questor | |
821 | +PERSIST_CONFIG="" | |
822 | +if [ ${SIMPLE_INST} -eq 1 ] && ([ ${CONF_PG} -eq 1 ] || [ ${CREATE_LB_DT} -eq 1 ]); then | |
823 | + | |
824 | + if [ ${CONF_PG} -eq 1 ] ; then | |
825 | + CONF_PG_VL=" | |
826 | + user ...... $PG_USER_F | |
827 | + password .. $PG_PWD_F" | |
828 | + fi | |
829 | + if [ ${CREATE_LB_DT} -eq 1 ] ; then | |
830 | + CREATE_LB_DT_VL=" | |
831 | + database .... $PG_DB_F" | |
832 | + fi | |
833 | + | |
834 | + PERSIST_CONFIG=" | |
835 | + LightBase (LBG) postgres 9.4 persistence config...$CREATE_LB_DT_VL$CONF_PG_VL | |
836 | +" | |
837 | +fi | |
838 | + | |
839 | +USEFUL_INFO_F=" To start/stop... | |
840 | + service httpd start | |
841 | + service httpd stop | |
842 | +$PERSIST_CONFIG | |
843 | + To access... | |
844 | + http://<ip>/$APP_URL_F | |
845 | + | |
846 | + To configure... | |
847 | + vi $BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini | |
848 | + | |
849 | + To configure httpd (Apache)... | |
850 | + vi /etc/httpd/conf.d/lbg.conf | |
851 | + | |
852 | + Log... | |
853 | + less /var/log/httpd/error_log" | |
854 | + | |
855 | +f_end "$TITLE_F" "$USEFUL_INFO_F" | |
856 | +TITLE_F="" | |
857 | +USEFUL_INFO_F="" | |
858 | + | |
859 | +# < -------------------------------------------------------------------------- | ... | ... |
1 | +++ a/lbn-basic-dt-strt/lbn_basic_dt_strt.sql | |
... | ... | @@ -0,0 +1,393 @@ |
1 | +/* --------------------------------------------------- */ | |
2 | +/* TABELAS DA INFRAESTRTURA BÁSICA DO LB */ | |
3 | +/* ------------------------ */ | |
4 | + | |
5 | +/* ----------------------------------- */ | |
6 | +/* lb_base */ | |
7 | +/* ------------- */ | |
8 | +/* [OK] */ | |
9 | + | |
10 | +CREATE TABLE lb_base | |
11 | +( | |
12 | + id_base serial NOT NULL, | |
13 | + name character varying NOT NULL, | |
14 | + struct character varying NOT NULL, | |
15 | + dt_base timestamp without time zone NOT NULL, | |
16 | + idx_exp boolean NOT NULL, | |
17 | + idx_exp_url character varying, | |
18 | + idx_exp_time integer, | |
19 | + file_ext boolean NOT NULL, | |
20 | + file_ext_time integer, | |
21 | + txt_mapping character varying, | |
22 | + CONSTRAINT lb_base_pkey PRIMARY KEY (id_base), | |
23 | + CONSTRAINT lb_base_name_key UNIQUE (name) | |
24 | +) | |
25 | +WITH ( | |
26 | + OIDS=FALSE | |
27 | +); | |
28 | +ALTER TABLE lb_base | |
29 | + OWNER TO postgres; | |
30 | + | |
31 | +/* ------ */ | |
32 | + | |
33 | +INSERT INTO public.lb_base (name,struct,dt_base,idx_exp,idx_exp_url,idx_exp_time,file_ext,file_ext_time) VALUES ( | |
34 | +'_app_config','{"content": [{"field": {"name": "nm_aplicacao", "datatype": "Text", "required": false, "alias": "Aplicação", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Define o nome da aplicação"}}, {"field": {"name": "nm_apelido", "datatype": "Text", "required": false, "alias": "nm_apelido", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Apelido da aplicação. Campo usado para identificar à qual aplicação o config pertence ou de qual aplicação. Oriundo da tabela Aplicação nm_apelido."}}, {"group": {"content": [{"field": {"name": "manual", "datatype": "File", "required": false, "alias": "manual", "multivalued": false, "indices": ["Textual"], "description": "Manuais"}}, {"field": {"name": "ch_manual", "datatype": "Text", "required": true, "alias": "Chave do manual", "multivalued": false, "indices": ["Textual"], "description": "Chave para tornar única a identificação de cada manual."}}, {"field": {"name": "nm_manual", "datatype": "Text", "required": true, "alias": "Nome do manual", "multivalued": false, "indices": ["Textual"], "description": "Nome do manual"}}, {"field": {"name": "color", "datatype": "Text", "required": false, "alias": "Cor", "multivalued": false, "indices": ["Textual"], "description": "Cor na qual aparece para download"}}, {"group": {"content": [{"field": {"name": "nr_cpf_user_alteracao", "datatype": "Text", "required": false, "alias": "Número do CPF do usuário da alteração", "multivalued": false, "indices": ["Textual"], "description": "Número do CPF do usuário da ultima alteração. Campo usado para informar o cpf do usuário que fez a ultima alteração."}}, {"field": {"name": "dt_alteracao", "datatype": "DateTime", "required": false, "alias": "Data e hora da alteração", "multivalued": false, "indices": ["Textual"], "description": "Data e Hora no formato DD/MM/AAAA - HH:MM:SS . Campo usado para informar a data e hora da alteração."}}, {"field": {"name": "nm_user_alteracao", "datatype": "Text", "required": false, "alias": "Nome do usuário da alteração", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Nome do usuário da alteração. Campo usado para informar o nome do usuário que fez a alteração."}}], "metadata": {"multivalued": true, "alias": "Alteração", "name": "alteracao", "description": "Alteração"}}}, {"group": {"content": [{"field": {"name": "nr_cpf_user_inclusao", "datatype": "Text", "required": false, "alias": "Número do CPF do usuário que incluiu.", "multivalued": false, "indices": ["Textual"], "description": "Número do CPF do usuário que incluiu. Campo usado para informar o cpf do usuário que fez a inclusão do registro."}}, {"field": {"name": "dt_inclusao", "datatype": "Text", "required": false, "alias": "Data e Hora da inclusão", "multivalued": false, "indices": ["Textual"], "description": "Data e Hora no formato DD/MM/AAAA - HH:MM:SS de inclusão do usuário no Cadastro. Campo usado para informar a data que o usuário foi incluído."}}, {"field": {"name": "nm_user_inclusao", "datatype": "Text", "required": false, "alias": "Nome do usuário que incluiu", "multivalued": false, "indices": ["Textual"], "description": "Nome do usuário que incluiu. Campo usado para informar o nome do usuário que realizou a inclusão do usuário."}}], "metadata": {"multivalued": false, "alias": "Inclusão", "name": "inclusao", "description": "Inclusão"}}}], "metadata": {"multivalued": true, "alias": "Manuais", "name": "manuais", "description": "Manuais"}}}], "metadata": {"idx_exp": false, "description": "Configurações da aplicação", "color": "#000000", "file_ext_time": 0, "dt_base": "01/01/2015 00:00:00", "idx_exp_url": "", "file_ext": false, "password": "12345678", "id_base": ID_BASE_PLACEHOLDER, "name": "_app_config", "idx_exp_time": 0, "model": {"manuais": [{"inclusao": {"dt_inclusao": "Text", "nr_cpf_user_inclusao": "Text", "nm_user_inclusao": "Text"}, "color": "Text", "manual": "File", "ch_manual": "Text", "nm_manual": "Text", "alteracao": [{"dt_alteracao": "DateTime", "nm_user_alteracao": "Text", "nr_cpf_user_alteracao": "Text"}]}], "nm_aplicacao": "Text", "nm_apelido": "Text"}}}',TO_DATE('2015-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),false,'',0,false,0); | |
35 | + | |
36 | +UPDATE lb_base SET struct = replace(struct, 'ID_BASE_PLACEHOLDER', cast(id_base as text)) WHERE name='_app_config'; | |
37 | + | |
38 | +/* ------ */ | |
39 | + | |
40 | +INSERT INTO public.lb_base (name,struct,dt_base,idx_exp,idx_exp_url,idx_exp_time,file_ext,file_ext_time) VALUES ( | |
41 | +'_history','{"content": [{"field": {"alias": "id_base", "description": "Base old ID.", "name": "id_base", "datatype": "Integer", "indices": ["Textual"], "required": true, "multivalued": false}}, {"field": {"alias": "author", "description": "Event Author.", "name": "author", "datatype": "Text", "indices": ["Textual"], "required": true, "multivalued": false}}, {"field": {"alias": "date", "description": "Event Date.", "name": "date", "datatype": "DateTime", "indices": ["Textual"], "required": true, "multivalued": false}}, {"field": {"alias": "name", "description": "Base old name.", "name": "name", "datatype": "Text", "indices": ["Textual"], "required": true, "multivalued": false}}, {"field": {"alias": "structure", "description": "Base old structure", "name": "structure", "datatype": "Json", "indices": ["Textual"], "required": true, "multivalued": false}}, {"field": {"alias": "status", "description": "Base status", "name": "status", "datatype": "Text", "indices": ["Textual"], "required": true, "multivalued": false}}], "metadata": {"idx_exp": false, "description": "LightBase - History Meta Base.", "color": "#000000", "file_ext_time": 10, "idx_exp_time": 0, "idx_exp_url": "", "model": {"status": "Text", "name": "Text", "author": "Text", "id_base": "Integer", "date": "DateTime", "structure": "Json"}, "password": "password", "dt_base": "01/01/2015 00:00:00", "file_ext": false, "id_base": ID_BASE_PLACEHOLDER, "name": "_history"}}',TO_DATE('2015-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),false,'',0,false,10); | |
42 | + | |
43 | +UPDATE lb_base SET struct = replace(struct, 'ID_BASE_PLACEHOLDER', cast(id_base as text)) WHERE name='_history'; | |
44 | + | |
45 | +/* ------ */ | |
46 | + | |
47 | +INSERT INTO public.lb_base (name,struct,dt_base,idx_exp,idx_exp_url,idx_exp_time,file_ext,file_ext_time) VALUES ( | |
48 | +'_portal','{"content": [{"field": {"name": "nm_portal", "datatype": "Text", "required": true, "alias": "Nome do Portal", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Contm o nome do portal. Usado para diferenciar os portais."}}, {"field": {"name": "alias_portal", "datatype": "Text", "required": true, "alias": "Apelido do Portal", "multivalued": false, "indices": ["Textual"], "description": "Este campo informa um apelido, possibilitando exibir um nome amigvel."}}, {"field": {"name": "ds_portal", "datatype": "Text", "required": true, "alias": "Descriço", "multivalued": false, "indices": ["Textual"], "description": "Contm um texto falando sobre o portal. Qual a finalidade do portal criado."}}, {"field": {"name": "cpf_user", "datatype": "Text", "required": false, "alias": "CPF do Usurio", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Indica o cpf do usurio que criou o portal. Auxilia a listar os portais de cada usurio"}}, {"group": {"content": [{"field": {"name": "nm_base", "datatype": "Text", "required": true, "alias": "Nome da Base", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome da base, deve ser o mesmo nome com o qual a base est salva no lightbase. Ser usado para auxiliar nas pesquisas feitas pelo portal."}}, {"field": {"name": "ds_base", "datatype": "Text", "required": true, "alias": "Apelido da Base", "multivalued": false, "indices": ["Textual"], "description": "Este campo informa um apelido, possibilitando exibir um nome amigvel no Portal de Pesquisas."}}, {"field": {"name": "url_index", "datatype": "Url", "required": false, "alias": "Url do Indexador", "multivalued": false, "indices": ["Textual"], "description": "Uma URL que indica o host onde ser feita a pesquisa via REST. Pode ser, por exemplo, a URL de um host com o ELastic Search instalado e com os dados indexados."}}, {"field": {"name": "url_detail", "datatype": "Url", "required": false, "alias": "URL de Detalhe", "multivalued": false, "indices": ["Textual"], "description": "Representa a URL da pgina de detalhes. O valor oriundo da aplicaço em questo, ou seja, de acordo a aplicaço referenciada o nome da pgina pode ser DetalhesRecebidos.aspx ou DetalhesExpedido.aspx"}}, {"field": {"name": "url_app", "datatype": "Url", "required": false, "alias": "Url da aplicaço", "multivalued": false, "indices": ["Textual"], "description": "Este campo usado para possibilitar links entre o portal e a aplicaço que utiliza esta base, como, por exemplo, abrir os detalhes de um registro pesquisado para abrir na pgina da aplicaço."}}, {"field": {"name": "nr_order", "datatype": "Integer", "required": false, "alias": "Ordem", "multivalued": false, "indices": ["Textual"], "description": "Auxilia a ordenar as abas no portal de pesquisa."}}, {"group": {"content": [{"group": {"content": [{"field": {"name": "nm_display_direct", "datatype": "Text", "required": false, "alias": "Nome exibido", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome com o qual o campo deve ser exibido na tela de pesquisa direta."}}, {"field": {"name": "in_display_direct", "datatype": "Boolean", "required": false, "alias": "Exibir?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo deve ser exibido na tela de pesquisa direta."}}, {"field": {"name": "nm_type_control_direct", "datatype": "Text", "required": false, "alias": "Tipo de controle", "multivalued": false, "indices": ["Textual"], "description": "Define o controle que deve ser carregado para o campo na tela de pesquisa direta."}}, {"field": {"name": "nr_position_direct", "datatype": "Integer", "required": false, "alias": "Posiço", "multivalued": false, "indices": ["Textual"], "description": "Contm um inteiro informando a posiço do campo na tela de pesquisa direta."}}, {"field": {"name": "script_direct", "datatype": "TextArea", "required": false, "alias": "script", "multivalued": false, "indices": ["Textual"], "description": "Contm um script que ser executado no momento que o campo for exibido na tela de pesquisa direta."}}], "metadata": {"multivalued": false, "alias": "Informaçes busca direta", "name": "inf_direct_search", "description": "Contm informaçes de como o campo se comporta na tela de busca direta."}}}, {"group": {"content": [{"field": {"name": "nm_display_advanced", "datatype": "Text", "required": false, "alias": "Nome exibido", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome com o qual o campo deve ser exibido na tela de pesquisa avançada."}}, {"field": {"name": "in_display_advanced", "datatype": "Boolean", "required": false, "alias": "Exibir?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo deve ser exibido na tela de pesquisa avançada."}}, {"field": {"name": "in_fixed_advanced", "datatype": "Boolean", "required": false, "alias": "Campo fixo?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo fixo na tela de pesquisa avançada. Nesta tela os campo so escolhidos dinamicamente e inseridos como argumento de pesquisa, mas se o campo for fixo ela j fica fixado na tela."}}, {"field": {"name": "nm_type_control_advanced", "datatype": "Text", "required": false, "alias": "Tipo de Controle", "multivalued": false, "indices": ["Textual"], "description": "Define o controle que deve ser carregado na pesquisa avançada para exibir este campo."}}, {"field": {"name": "script_advanced", "datatype": "TextArea", "required": false, "alias": "script", "multivalued": false, "indices": ["Textual"], "description": "Contm um script para ser executado na pgina nome momento em que o campo exibido."}}], "metadata": {"multivalued": false, "alias": "Informaçes pesquisa avançada", "name": "inf_advanced_search", "description": "Contm informaçes que definem como o campo se comporta na tela de pesquisa avançada."}}}, {"group": {"content": [{"field": {"name": "nm_display_listed", "datatype": "Text", "required": false, "alias": "Nome exibido", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome que deve exibido na coluna da tabela resultado de pesquisa."}}, {"field": {"name": "in_select_listed", "datatype": "Boolean", "required": false, "alias": "Recuperar?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo deve ser selecionado no resultado de pesquisa, ou seja, recuperado nas consultas."}}, {"field": {"name": "in_display_listed", "datatype": "Boolean", "required": false, "alias": "Exibir?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo deve ser exibido no resultado de pesquisa"}}, {"field": {"name": "in_search_listed", "datatype": "Boolean", "required": false, "alias": "Pesquisar?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo usado na pesquisa. Essa informaço relevante para a pesquisa direta, que realiza a busca nos campos que contm essa flag marcada com true."}}, {"field": {"name": "nr_position_listed", "datatype": "Integer", "required": false, "alias": "Posiço", "multivalued": false, "indices": ["Textual"], "description": "Defina a posiço da coluna na tabela de resultado de pesquisa."}}, {"field": {"name": "script_listed", "datatype": "TextArea", "required": false, "alias": "script", "multivalued": false, "indices": ["Textual"], "description": "Contm um script que ser executado na exibiço do campo na tabela de resultado de pesquisa. til para criar botes, links, etc."}}, {"field": {"name": "in_sortable_listed", "datatype": "Boolean", "required": false, "alias": "Ordenar?", "multivalued": false, "indices": ["Textual"], "description": "Indica se a coluna ordenvel na tabela do resultado de pesquisa."}}], "metadata": {"multivalued": false, "alias": "Informaçes resultado de pesquisa", "name": "inf_listed_search", "description": "Contm as informaçes do campo de como se comportar na pesquisa listada."}}}, {"group": {"content": [{"field": {"name": "nm_display_detailed", "datatype": "Text", "required": false, "alias": "Nome exibido", "multivalued": false, "indices": ["Textual"], "description": "contm o nome com o qual o campo deve ser exibido na tela de detalhes."}}, {"field": {"name": "in_display_detailed", "datatype": "Boolean", "required": false, "alias": "Exibir?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag dizendo se o campo exibido ou no tela de detalhes."}}, {"field": {"name": "in_search_detailed", "datatype": "Boolean", "required": false, "alias": "Pesquisar?", "multivalued": false, "indices": ["Textual"], "description": "Contm uma flag informando se o campo pesquisado para chamar a pgina de detalhes."}}, {"field": {"name": "nr_position_detailed", "datatype": "Integer", "required": false, "alias": "Posiço", "multivalued": false, "indices": ["Textual"], "description": "Contm um inteiro informando a posiço do campo na tela de detalhes."}}, {"field": {"name": "script_detailed", "datatype": "TextArea", "required": false, "alias": "Script", "multivalued": false, "indices": ["Textual"], "description": "Contm um script que deve ser executado na exibiço do campo na pgina de detalhes. Por exemplo, criar um link dentro campo."}}], "metadata": {"multivalued": false, "alias": "Informaçes da tela de detalhes", "name": "inf_detailed_search", "description": "Contm as informaçes de como o campo se comporta na tela de detalhes. Caso esta tela seja tratada no portal, pois ela pode ser de outra aplicaço e neste caso usasse o campo url_detail."}}}, {"group": {"content": [{"field": {"name": "data_tabulated", "datatype": "Json", "required": false, "alias": "Lista de dados", "multivalued": false, "indices": ["Textual"], "description": "Contm uma lista de objetos json. Serve para criar uma tabela esttica com os campo tabelados. Por exemplo, uma tabela de siglas e nomes de estados."}}, {"field": {"name": "nm_field_value_tabulated", "datatype": "Text", "required": false, "alias": "Nome do campo valor", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome do campo da base referenciada que contm o valor."}}, {"field": {"name": "nm_field_key_tabulated", "datatype": "Text", "required": false, "alias": "Nome Campo Chave", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome do campo da base referenciada que contm a chave do valor."}}, {"field": {"name": "relational_key_tabulated", "datatype": "Text", "required": false, "alias": "Chave relacional", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome da coluna que contm a chave da relaço. o campo referenciado na base."}}, {"field": {"name": "nm_table_tabulated", "datatype": "Text", "required": false, "alias": "Nome da tabela referenciada", "multivalued": false, "indices": ["Textual"], "description": "Contm o nome da tabela que est sendo usada para tabelar o campo."}}], "metadata": {"multivalued": false, "alias": "Informaçes Campo Tabelado", "name": "inf_field_tabulated", "description": "Define as informaçes de campos tabelados. S precisa ser preenchido se o tipo de campo for igual a tabulated."}}}, {"field": {"name": "groups_can_view", "datatype": "Text", "required": false, "alias": "Grupos", "multivalued": true, "indices": ["Textual"], "description": "Define os grupos que podem visualizar o campo."}}, {"field": {"name": "ds_field", "datatype": "Text", "required": false, "alias": "Apelido do campo", "multivalued": false, "indices": ["Textual"], "description": "Define o apelido do campo. um nome mais amigvel para ser exibido no portal."}}, {"field": {"name": "nm_field", "datatype": "Text", "required": true, "alias": "Nome do campo", "multivalued": false, "indices": ["Textual"], "description": "Nome do campo da base. Deve coincidir com o nome do campo que est salvo no lightbase."}}, {"field": {"name": "nm_type_field", "datatype": "Text", "required": true, "alias": "Tipo de campo", "multivalued": false, "indices": ["Textual"], "description": "Indica qual o tipo de campo. utilizado pelo portal para saber como exibir o campo. oriundo dos tipos de campo que o lightbase usa para criar campos."}}], "metadata": {"multivalued": true, "alias": "Campo", "name": "field", "description": "Representa os campos da base. Informa onde e como sero usados pelo portal."}}}], "metadata": {"multivalued": true, "alias": "Bases do Portal", "name": "bases", "description": "Contm as Bases do portal."}}}], "metadata": {"idx_exp": false, "description": "Novo conceito do portal. Uma base _portal lista todos os portais separados por nome e com o id do usu-ario que criou.", "color": "", "file_ext_time": 0, "dt_base": "01/01/2015 00:00:00", "idx_exp_url": "", "file_ext": false, "password": "BRLight@)!$", "id_base": ID_BASE_PLACEHOLDER, "name": "_portal", "idx_exp_time": 0, "model": {"alias_portal": "Text", "cpf_user": "Text", "bases": [{"url_index": "Url", "nm_base": "Text", "field": [{"inf_advanced_search": {"in_fixed_advanced": "Boolean", "in_display_advanced": "Boolean", "nm_type_control_advanced": "Text", "nm_display_advanced": "Text", "script_advanced": "TextArea"}, "inf_listed_search": {"in_search_listed": "Boolean", "nm_display_listed": "Text", "in_select_listed": "Boolean", "in_sortable_listed": "Boolean", "nr_position_listed": "Integer", "script_listed": "TextArea", "in_display_listed": "Boolean"}, "inf_field_tabulated": {"nm_table_tabulated": "Text", "nm_field_key_tabulated": "Text", "relational_key_tabulated": "Text", "data_tabulated": "Json", "nm_field_value_tabulated": "Text"}, "inf_direct_search": {"nr_position_direct": "Integer", "nm_display_direct": "Text", "script_direct": "TextArea", "nm_type_control_direct": "Text", "in_display_direct": "Boolean"}, "groups_can_view": ["Text"], "ds_field": "Text", "nm_type_field": "Text", "nm_field": "Text", "inf_detailed_search": {"nm_display_detailed": "Text", "in_search_detailed": "Boolean", "in_display_detailed": "Boolean", "script_detailed": "TextArea", "nr_position_detailed": "Integer"}}], "url_detail": "Url", "url_app": "Url", "nr_order": "Integer", "ds_base": "Text"}], "nm_portal": "Text", "ds_portal": "Text"}}}',TO_DATE('2015-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),false,'',0,false,0); | |
49 | + | |
50 | +UPDATE lb_base SET struct = replace(struct, 'ID_BASE_PLACEHOLDER', cast(id_base as text)) WHERE name='_portal'; | |
51 | + | |
52 | +/* ------ */ | |
53 | + | |
54 | +INSERT INTO public.lb_base (name,struct,dt_base,idx_exp,idx_exp_url,idx_exp_time,file_ext,file_ext_time) VALUES ( | |
55 | +'_user','{"content": [{"field": {"alias": "id", "description": "LightBase''s uses ID", "name": "id_user", "datatype": "Integer", "indices": ["Textual", "Ordenado"], "required": true, "multivalued": false}}, {"field": {"alias": "name", "description": "User''s name", "name": "name_user", "datatype": "Text", "indices": ["Textual", "Ordenado"], "required": true, "multivalued": false}}, {"field": {"alias": "email", "description": "User''s mail", "name": "email_user", "datatype": "Text", "indices": ["Textual", "Ordenado"], "required": true, "multivalued": false}}, {"field": {"alias": "passwd", "description": "User''s password", "name": "passwd_user", "datatype": "Text", "indices": ["Textual", "Ordenado"], "required": true, "multivalued": false}}, {"group": {"content": [{"field": {"alias": "name_base", "description": "Name of the base the user can access", "name": "name_base", "datatype": "Text", "indices": ["Textual", "Ordenado", "Fuzzy"], "required": false, "multivalued": false}}, {"field": {"alias": "access_type", "description": "Type of access the user has", "name": "access_type", "datatype": "Text", "indices": ["Textual", "Ordenado"], "required": false, "multivalued": false}}], "metadata": {"alias": "bases", "description": "List of bases that the user can access and what kind of access it is", "multivalued": true, "name": "bases_user"}}}, {"field": {"alias": "creation_date", "description": "Date the user account was created", "name": "creation_date_user", "datatype": "Date", "indices": ["Textual", "Ordenado"], "required": true, "multivalued": false}}, {"field": {"alias": "status", "description": "Check if the user is activer or not", "name": "status_user", "datatype": "Boolean", "indices": ["Textual", "Ordenado"], "required": true, "multivalued": false}}], "metadata": {"idx_exp": false, "description": "LightBase''s Users Meta Base.", "color": "#000000", "file_ext_time": 0, "idx_exp_time": 0, "idx_exp_url": "", "model": {"name_user": "Text", "status_user": "Boolean", "bases_user": [{"name_base": "Text", "access_type": "Text"}], "id_user": "Integer", "creation_date_user": "Date", "email_user": "Text", "passwd_user": "Text"}, "password": "3Ax!vj6gV#DEtR", "dt_base": "01/01/2015 00:00:00", "file_ext": false, "id_base": ID_BASE_PLACEHOLDER, "name": "_user"}}',TO_DATE('2015-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),false,'',0,false,0); | |
56 | + | |
57 | +UPDATE lb_base SET struct = replace(struct, 'ID_BASE_PLACEHOLDER', cast(id_base as text)) WHERE name='_user'; | |
58 | + | |
59 | +/* ------ */ | |
60 | + | |
61 | +INSERT INTO public.lb_base (name,struct,dt_base,idx_exp,idx_exp_url,idx_exp_time,file_ext,file_ext_time) VALUES ( | |
62 | +'log_lbconverter','{"content": [{"field": {"name": "nm_base", "datatype": "Text", "required": true, "alias": "Nome da base", "multivalued": false, "indices": ["Ordenado"], "description": "Nome da base"}}, {"field": {"name": "id_doc_orig", "datatype": "Integer", "required": true, "alias": "id_doc_orig", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "id do documento que originou o erro."}}, {"field": {"name": "id_file_orig", "datatype": "Text", "required": true, "alias": "id_file_orig", "multivalued": false, "indices": ["Textual", "Unico"], "description": "ID do arquivo que originou o erro."}}, {"field": {"name": "file_name", "datatype": "Text", "required": true, "alias": "file_name", "multivalued": false, "indices": ["Ordenado"], "description": "File name"}}, {"field": {"name": "error_msg", "datatype": "Text", "required": true, "alias": "Mensagem de erro", "multivalued": false, "indices": ["Nenhum"], "description": "Mensagem de erro"}}, {"field": {"name": "dt_error", "datatype": "DateTime", "required": true, "alias": "Data do erro", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Data do erro"}}], "metadata": {"idx_exp": false, "description": "LightBase - Log de erros do LBConverter", "color": "#000000", "file_ext_time": 0, "dt_base": "01/01/2015 00:00:00", "idx_exp_url": "", "file_ext": false, "password": "qqqqqqqq", "id_base": ID_BASE_PLACEHOLDER, "name": "log_lbconverter", "idx_exp_time": 0, "model": {"id_file_orig": "Text", "nm_base": "Text", "file_name": "Text", "id_doc_orig": "Integer", "dt_error": "DateTime", "error_msg": "Text"}}}',TO_DATE('2015-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),false,'',0,false,0); | |
63 | + | |
64 | +UPDATE lb_base SET struct = replace(struct, 'ID_BASE_PLACEHOLDER', cast(id_base as text)) WHERE name='log_lbconverter'; | |
65 | + | |
66 | +/* ------ */ | |
67 | + | |
68 | +INSERT INTO public.lb_base (name,struct,dt_base,idx_exp,idx_exp_url,idx_exp_time,file_ext,file_ext_time) VALUES ( | |
69 | +'log_lbindex','{"content": [{"field": {"name": "nm_base", "datatype": "Text", "required": true, "alias": "Nome da base", "multivalued": false, "indices": ["Ordenado"], "description": "Nome da base"}}, {"field": {"name": "id_doc_orig", "datatype": "Integer", "required": true, "alias": "identificador do documento", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "id do documento que originou o erro."}}, {"field": {"name": "error_msg", "datatype": "Text", "required": true, "alias": "Mensagem de erro", "multivalued": false, "indices": ["Nenhum"], "description": "Mensagem de erro"}}, {"field": {"name": "dt_error", "datatype": "DateTime", "required": true, "alias": "Data do erro", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Data e Hora no formato DD/MM/AAAA - HH:MM:SS do erro"}}, {"field": {"name": "dt_last_up_orig", "datatype": "DateTime", "required": true, "alias": "dt_last_up_orig", "multivalued": false, "indices": ["Textual", "Ordenado"], "description": "Data e Hora no formato DD/MM/AAAA - HH:MM:SS da última atualização do registro que originou o erro."}}], "metadata": {"idx_exp": false, "description": "LightBase - Log de erros do LBIndex", "color": "#000000", "file_ext_time": 0, "dt_base": "01/01/2015 00:00:00", "idx_exp_url": "", "file_ext": false, "password": "qqqqqqqq", "id_base": ID_BASE_PLACEHOLDER, "name": "log_lbindex", "idx_exp_time": 0, "model": {"dt_last_up_orig": "DateTime", "id_doc_orig": "Integer", "dt_error": "DateTime", "error_msg": "Text", "nm_base": "Text"}}}',TO_DATE('2015-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),false,'',0,false,0); | |
70 | + | |
71 | +UPDATE lb_base SET struct = replace(struct, 'ID_BASE_PLACEHOLDER', cast(id_base as text)) WHERE name='log_lbindex'; | |
72 | + | |
73 | +/* ------ */ | |
74 | + | |
75 | +/* ----------------------------------- */ | |
76 | +/* _app_config */ | |
77 | +/* ------------- */ | |
78 | +/* [OK] */ | |
79 | + | |
80 | +CREATE TABLE lb_doc__app_config | |
81 | +( | |
82 | + id_doc serial NOT NULL, | |
83 | + document json NOT NULL, | |
84 | + dt_doc timestamp without time zone NOT NULL, | |
85 | + dt_last_up timestamp without time zone NOT NULL, | |
86 | + dt_del timestamp without time zone, | |
87 | + dt_idx timestamp without time zone, | |
88 | + nm_user_alteracao character varying[], | |
89 | + nm_apelido character varying, | |
90 | + nm_aplicacao character varying, | |
91 | + CONSTRAINT lb_doc__app_config_pkey PRIMARY KEY (id_doc) | |
92 | +) | |
93 | +WITH ( | |
94 | + OIDS=FALSE | |
95 | +); | |
96 | +ALTER TABLE lb_doc__app_config | |
97 | + OWNER TO postgres; | |
98 | + | |
99 | +/* ------ */ | |
100 | +/* [OK] */ | |
101 | + | |
102 | +CREATE TABLE lb_file__app_config | |
103 | +( | |
104 | + id_file uuid NOT NULL, | |
105 | + id_doc integer, | |
106 | + filename character varying NOT NULL, | |
107 | + file bytea NOT NULL, | |
108 | + mimetype character varying NOT NULL, | |
109 | + filesize integer NOT NULL, | |
110 | + filetext character varying, | |
111 | + dt_ext_text timestamp without time zone, | |
112 | + CONSTRAINT lb_file__app_config_pkey PRIMARY KEY (id_file) | |
113 | +) | |
114 | +WITH ( | |
115 | + OIDS=FALSE | |
116 | +); | |
117 | +ALTER TABLE lb_file__app_config | |
118 | + OWNER TO postgres; | |
119 | + | |
120 | +/* ----------------------------------- */ | |
121 | +/* _history */ | |
122 | +/* ------------- */ | |
123 | +/* [OK] */ | |
124 | + | |
125 | +CREATE TABLE lb_doc__history | |
126 | +( | |
127 | + id_doc serial NOT NULL, | |
128 | + document json NOT NULL, | |
129 | + dt_doc timestamp without time zone NOT NULL, | |
130 | + dt_last_up timestamp without time zone NOT NULL, | |
131 | + dt_del timestamp without time zone, | |
132 | + dt_idx timestamp without time zone, | |
133 | + CONSTRAINT lb_doc__history_pkey PRIMARY KEY (id_doc) | |
134 | +) | |
135 | +WITH ( | |
136 | + OIDS=FALSE | |
137 | +); | |
138 | +ALTER TABLE lb_doc__history | |
139 | + OWNER TO postgres; | |
140 | + | |
141 | +/* ------ */ | |
142 | +/* [OK] */ | |
143 | + | |
144 | +CREATE TABLE lb_file__history | |
145 | +( | |
146 | + id_file uuid NOT NULL, | |
147 | + id_doc integer, | |
148 | + filename character varying NOT NULL, | |
149 | + file bytea NOT NULL, | |
150 | + mimetype character varying NOT NULL, | |
151 | + filesize integer NOT NULL, | |
152 | + filetext character varying, | |
153 | + dt_ext_text timestamp without time zone, | |
154 | + CONSTRAINT lb_file__history_pkey PRIMARY KEY (id_file) | |
155 | +) | |
156 | +WITH ( | |
157 | + OIDS=FALSE | |
158 | +); | |
159 | +ALTER TABLE lb_file__history | |
160 | + OWNER TO postgres; | |
161 | + | |
162 | +/* ----------------------------------- */ | |
163 | +/* _portal */ | |
164 | +/* ------------- */ | |
165 | +/* [OK] */ | |
166 | + | |
167 | +CREATE TABLE lb_doc__portal | |
168 | +( | |
169 | + id_doc serial NOT NULL, | |
170 | + document json NOT NULL, | |
171 | + dt_doc timestamp without time zone NOT NULL, | |
172 | + dt_last_up timestamp without time zone NOT NULL, | |
173 | + dt_del timestamp without time zone, | |
174 | + dt_idx timestamp without time zone, | |
175 | + cpf_user character varying, | |
176 | + nm_portal character varying, | |
177 | + CONSTRAINT lb_doc__portal_pkey PRIMARY KEY (id_doc) | |
178 | +) | |
179 | +WITH ( | |
180 | + OIDS=FALSE | |
181 | +); | |
182 | +ALTER TABLE lb_doc__portal | |
183 | + OWNER TO postgres; | |
184 | + | |
185 | +/* ------ */ | |
186 | +/* [OK] */ | |
187 | + | |
188 | +CREATE TABLE lb_file__portal | |
189 | +( | |
190 | + id_file uuid NOT NULL, | |
191 | + id_doc integer, | |
192 | + filename character varying NOT NULL, | |
193 | + file bytea NOT NULL, | |
194 | + mimetype character varying NOT NULL, | |
195 | + filesize integer NOT NULL, | |
196 | + filetext character varying, | |
197 | + dt_ext_text timestamp without time zone, | |
198 | + CONSTRAINT lb_file__portal_pkey PRIMARY KEY (id_file) | |
199 | +) | |
200 | +WITH ( | |
201 | + OIDS=FALSE | |
202 | +); | |
203 | +ALTER TABLE lb_file__portal | |
204 | + OWNER TO postgres; | |
205 | + | |
206 | +/* ----------------------------------- */ | |
207 | +/* _user */ | |
208 | +/* ------------- */ | |
209 | +/* [OK] */ | |
210 | + | |
211 | +CREATE TABLE lb_doc__user | |
212 | +( | |
213 | + id_doc serial NOT NULL, | |
214 | + document json NOT NULL, | |
215 | + dt_doc timestamp without time zone NOT NULL, | |
216 | + dt_last_up timestamp without time zone NOT NULL, | |
217 | + dt_del timestamp without time zone, | |
218 | + dt_idx timestamp without time zone, | |
219 | + name_base character varying[], | |
220 | + id_user integer, | |
221 | + status_user boolean, | |
222 | + access_type character varying[], | |
223 | + name_user character varying, | |
224 | + creation_date_user date, | |
225 | + email_user character varying, | |
226 | + passwd_user character varying, | |
227 | + CONSTRAINT lb_doc__user_pkey PRIMARY KEY (id_doc) | |
228 | +) | |
229 | +WITH ( | |
230 | + OIDS=FALSE | |
231 | +); | |
232 | +ALTER TABLE lb_doc__user | |
233 | + OWNER TO postgres; | |
234 | + | |
235 | +/* ------ */ | |
236 | +/* [OK] */ | |
237 | + | |
238 | +CREATE TABLE lb_file__user | |
239 | +( | |
240 | + id_file uuid NOT NULL, | |
241 | + id_doc integer, | |
242 | + filename character varying NOT NULL, | |
243 | + file bytea NOT NULL, | |
244 | + mimetype character varying NOT NULL, | |
245 | + filesize integer NOT NULL, | |
246 | + filetext character varying, | |
247 | + dt_ext_text timestamp without time zone, | |
248 | + CONSTRAINT lb_file__user_pkey PRIMARY KEY (id_file) | |
249 | +) | |
250 | +WITH ( | |
251 | + OIDS=FALSE | |
252 | +); | |
253 | +ALTER TABLE lb_file__user | |
254 | + OWNER TO postgres; | |
255 | + | |
256 | +/* ----------------------------------- */ | |
257 | +/* lb_index_error */ | |
258 | +/* ------------- */ | |
259 | +/* [OK] */ | |
260 | + | |
261 | +CREATE TABLE lb_index_error | |
262 | +( | |
263 | + id_error serial NOT NULL, | |
264 | + base character varying NOT NULL, | |
265 | + id_doc integer NOT NULL, | |
266 | + dt_error timestamp without time zone NOT NULL, | |
267 | + msg_error character varying, | |
268 | + CONSTRAINT lb_index_error_pkey PRIMARY KEY (id_error) | |
269 | +) | |
270 | +WITH ( | |
271 | + OIDS=FALSE | |
272 | +); | |
273 | +ALTER TABLE lb_index_error | |
274 | + OWNER TO postgres; | |
275 | + | |
276 | +/* ----------------------------------- */ | |
277 | +/* log_lbindex */ | |
278 | +/* ------------- */ | |
279 | +/* [OK] */ | |
280 | + | |
281 | +CREATE TABLE lb_doc_log_lbindex | |
282 | +( | |
283 | + id_doc serial NOT NULL, | |
284 | + document json NOT NULL, | |
285 | + dt_doc timestamp without time zone NOT NULL, | |
286 | + dt_last_up timestamp without time zone NOT NULL, | |
287 | + dt_del timestamp without time zone, | |
288 | + dt_idx timestamp without time zone, | |
289 | + id_doc_orig integer, | |
290 | + dt_last_up_orig timestamp without time zone, | |
291 | + nm_base character varying, | |
292 | + dt_error timestamp without time zone, | |
293 | + CONSTRAINT lb_doc_log_lbindex_pkey PRIMARY KEY (id_doc) | |
294 | +) | |
295 | +WITH ( | |
296 | + OIDS=FALSE | |
297 | +); | |
298 | +ALTER TABLE lb_doc_log_lbindex | |
299 | + OWNER TO postgres; | |
300 | + | |
301 | +/* ------ */ | |
302 | +/* [OK] */ | |
303 | + | |
304 | +CREATE TABLE lb_file_log_lbindex | |
305 | +( | |
306 | + id_file uuid NOT NULL, | |
307 | + id_doc integer, | |
308 | + filename character varying NOT NULL, | |
309 | + file bytea NOT NULL, | |
310 | + mimetype character varying NOT NULL, | |
311 | + filesize integer NOT NULL, | |
312 | + filetext character varying, | |
313 | + dt_ext_text timestamp without time zone, | |
314 | + CONSTRAINT lb_file_log_lbindex_pkey PRIMARY KEY (id_file) | |
315 | +) | |
316 | +WITH ( | |
317 | + OIDS=FALSE | |
318 | +); | |
319 | +ALTER TABLE lb_file_log_lbindex | |
320 | + OWNER TO postgres; | |
321 | + | |
322 | +/* ----------------------------------- */ | |
323 | +/* log_lbconverter */ | |
324 | +/* ------------- */ | |
325 | +/* [OK] */ | |
326 | + | |
327 | +CREATE TABLE lb_doc_log_lbconverter | |
328 | +( | |
329 | + id_doc serial NOT NULL, | |
330 | + document json NOT NULL, | |
331 | + dt_doc timestamp without time zone NOT NULL, | |
332 | + dt_last_up timestamp without time zone NOT NULL, | |
333 | + dt_del timestamp without time zone, | |
334 | + dt_idx timestamp without time zone, | |
335 | + file_name character varying, | |
336 | + id_doc_orig integer, | |
337 | + nm_base character varying, | |
338 | + dt_error timestamp without time zone, | |
339 | + CONSTRAINT lb_doc_log_lbconverter_pkey PRIMARY KEY (id_doc) | |
340 | +) | |
341 | +WITH ( | |
342 | + OIDS=FALSE | |
343 | +); | |
344 | +ALTER TABLE lb_doc_log_lbconverter | |
345 | + OWNER TO postgres; | |
346 | + | |
347 | +/* ------ */ | |
348 | +/* [OK] */ | |
349 | + | |
350 | +CREATE TABLE lb_file_log_lbconverter | |
351 | +( | |
352 | + id_file uuid NOT NULL, | |
353 | + id_doc integer, | |
354 | + filename character varying NOT NULL, | |
355 | + file bytea NOT NULL, | |
356 | + mimetype character varying NOT NULL, | |
357 | + filesize integer NOT NULL, | |
358 | + filetext character varying, | |
359 | + dt_ext_text timestamp without time zone, | |
360 | + CONSTRAINT lb_file_log_lbconverter_pkey PRIMARY KEY (id_file) | |
361 | +) | |
362 | +WITH ( | |
363 | + OIDS=FALSE | |
364 | +); | |
365 | +ALTER TABLE lb_file_log_lbconverter | |
366 | + OWNER TO postgres; | |
367 | + | |
368 | +/* ----------------------------------- */ | |
369 | +/* lb_txt_idx */ | |
370 | +/* ------------- */ | |
371 | +/* [OK] */ | |
372 | + | |
373 | +CREATE TABLE lb_txt_idx | |
374 | +( | |
375 | + id_idx serial NOT NULL, | |
376 | + nm_idx character varying NOT NULL, | |
377 | + cfg_idx character varying NOT NULL, | |
378 | + dt_crt_idx timestamp without time zone NOT NULL, | |
379 | + dt_upt_idx timestamp without time zone NOT NULL, | |
380 | + url_idx character varying NOT NULL, | |
381 | + actv_idx boolean NOT NULL, | |
382 | + struct character varying NOT NULL, | |
383 | + CONSTRAINT lb_txt_idx_pkey PRIMARY KEY (id_idx), | |
384 | + CONSTRAINT lb_txt_idx_nm_idx_key UNIQUE (nm_idx) | |
385 | +) | |
386 | +WITH ( | |
387 | + OIDS=FALSE | |
388 | +); | |
389 | +ALTER TABLE lb_txt_idx | |
390 | + OWNER TO postgres; | |
391 | +\q | |
392 | + | |
393 | +/* --------------------------------------------------- */ | |
0 | 394 | \ No newline at end of file | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +++ a/other-srcs-n-apps/lbg.conf.dist | |
... | ... | @@ -0,0 +1,23 @@ |
1 | +# Use only 1 Python sub-interpreter. Multiple sub-interpreters | |
2 | +# play badly with C extensions. | |
3 | + | |
4 | +LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so | |
5 | + | |
6 | +WSGISocketPrefix /var/run/wsgi | |
7 | + | |
8 | +ServerAdmin admin@lightbase.com.br | |
9 | +ServerName 127.0.0.1 | |
10 | + | |
11 | +WSGIApplicationGroup %{GLOBAL} | |
12 | +WSGIPassAuthorization On | |
13 | +WSGIDaemonProcess <LBG_URL> user=apache group=apache threads=8 python-path=<VE32_PATH>/lib/python3.2/site-packages | |
14 | +WSGIScriptAlias /<LBG_URL> <VE32_PATH>/src/LBGenerator/lbgenerator.wsgi | |
15 | + | |
16 | +<Directory <VE32_PATH>> | |
17 | + WSGIProcessGroup <LBG_URL> | |
18 | + Order allow,deny | |
19 | + Allow from all | |
20 | +</Directory> | |
21 | + | |
22 | +ErrorLog /var/log/httpd/neo-lightbase-error.log | |
23 | +CustomLog /var/log/httpd/neo-lightbase-access.log combined | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +++ a/py-packs-LBGenerator.sh | |
... | ... | @@ -0,0 +1,155 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +# Instalação das dependências do LBG - LBGenerator no python3.2! | |
4 | + | |
5 | +. ./ez_i.sh | |
6 | + | |
7 | +SKIP_ON_V=$1 | |
8 | +if [ -z "$SKIP_ON_V" ] ; then | |
9 | + SKIP_ON_V=0 | |
10 | +fi | |
11 | + | |
12 | +BASE_INST_DIR_V=$2 | |
13 | + | |
14 | +# > ----------------------------------------- | |
15 | +# Informar o diretório base da instalação! | |
16 | + | |
17 | +if [ -z "$BASE_INST_DIR_V" ] ; then | |
18 | + f_open_section | |
19 | + BASE_INST_DIR_V="/usr/local/lb" | |
20 | + | |
21 | + QUESTION_F="Enter the installation directory. | |
22 | + Use empty for \"$BASE_INST_DIR_V\"!" | |
23 | + | |
24 | + f_get_usr_input "$QUESTION_F" 1 | |
25 | + QUESTION_F="" | |
26 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
27 | + BASE_INST_DIR_V="$GET_USR_INPUT_R/lb" | |
28 | + fi | |
29 | + f_close_section | |
30 | +fi | |
31 | + | |
32 | +# < ----------------------------------------- | |
33 | + | |
34 | +f_open_section | |
35 | + | |
36 | +TITLE_F="Install LBGenerator dependencies for python3.2?" | |
37 | + | |
38 | +f_yes_no "$TITLE_F" | |
39 | +TITLE_F="" | |
40 | + | |
41 | +if [ ${YES_NO_R} -eq 1 ] || [ ${SKIP_ON_V} -eq 1 ] ; then | |
42 | + | |
43 | + cd "$SCRIPTDIR_V" | |
44 | + cd ./py-packs-LBGenerator | |
45 | + | |
46 | + tar -zxvf ./SQLAlchemy-0.9.4.tar.gz | |
47 | + cd ./SQLAlchemy-0.9.4 | |
48 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
49 | + cd .. | |
50 | + rm -rf ./SQLAlchemy-0.9.4 | |
51 | + | |
52 | + tar -zxvf ./Mako-1.0.1.tar.gz | |
53 | + cd ./Mako-1.0.1 | |
54 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
55 | + cd .. | |
56 | + rm -rf ./Mako-1.0.1 | |
57 | + | |
58 | + tar -zxvf ./alembic-0.6.7.tar.gz | |
59 | + cd ./alembic-0.6.7 | |
60 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
61 | + cd .. | |
62 | + rm -rf ./alembic-0.6.7 | |
63 | + | |
64 | + tar -zxvf ./Beaker-1.7.0.tar.gz | |
65 | + cd ./Beaker-1.7.0 | |
66 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
67 | + cd .. | |
68 | + rm -rf ./Beaker-1.7.0 | |
69 | + | |
70 | + tar -zxvf ./PasteDeploy-1.5.2.tar.gz | |
71 | + cd ./PasteDeploy-1.5.2 | |
72 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
73 | + cd .. | |
74 | + rm -rf ./PasteDeploy-1.5.2 | |
75 | + | |
76 | + tar -zxvf ./psycopg2-2.5.3.tar.gz | |
77 | + cd ./psycopg2-2.5.3 | |
78 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
79 | + cd .. | |
80 | + rm -rf ./psycopg2-2.5.3 | |
81 | + | |
82 | + tar -zxvf ./WebOb-1.4.tar.gz | |
83 | + cd ./WebOb-1.4 | |
84 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
85 | + cd .. | |
86 | + rm -rf ./WebOb-1.4 | |
87 | + | |
88 | + tar -zxvf ./translationstring-1.1.tar.gz | |
89 | + cd ./translationstring-1.1 | |
90 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
91 | + cd .. | |
92 | + rm -rf ./translationstring-1.1 | |
93 | + | |
94 | + tar -zxvf ./venusian-1.0a8.tar.gz | |
95 | + cd ./venusian-1.0a8 | |
96 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
97 | + cd .. | |
98 | + rm -rf ./venusian-1.0a8 | |
99 | + | |
100 | + tar -zxvf ./waitress-0.8.9.tar.gz | |
101 | + cd ./waitress-0.8.9 | |
102 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
103 | + cd .. | |
104 | + rm -rf ./waitress-0.8.9 | |
105 | + | |
106 | + tar -zxvf ./zope.deprecation-4.1.1.tar.gz | |
107 | + cd ./zope.deprecation-4.1.1 | |
108 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
109 | + cd .. | |
110 | + rm -rf ./zope.deprecation-4.1.1 | |
111 | + | |
112 | + tar -zxvf ./zope.interface-4.1.1.tar.gz | |
113 | + cd ./zope.interface-4.1.1 | |
114 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
115 | + cd .. | |
116 | + rm -rf ./zope.interface-4.1.1 | |
117 | + | |
118 | + tar -zxvf ./repoze.lru-0.6.tar.gz | |
119 | + cd ./repoze.lru-0.6 | |
120 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
121 | + cd .. | |
122 | + rm -rf ./repoze.lru-0.6 | |
123 | + | |
124 | + tar -zxvf ./pyramid-1.5.1.tar.gz | |
125 | + cd ./pyramid-1.5.1 | |
126 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
127 | + cd .. | |
128 | + rm -rf ./pyramid-1.5.1 | |
129 | + | |
130 | + tar -zxvf ./pyramid_beaker-0.8.tar.gz | |
131 | + cd ./pyramid_beaker-0.8 | |
132 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
133 | + cd .. | |
134 | + rm -rf ./pyramid_beaker-0.8 | |
135 | + | |
136 | + tar -zxvf ./pyramid_restler-0.1a4.tar.gz | |
137 | + cd ./pyramid_restler-0.1a4 | |
138 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
139 | + cd .. | |
140 | + rm -rf ./pyramid_restler-0.1a4 | |
141 | + | |
142 | + tar -zxvf ./requests-2.3.0.tar.gz | |
143 | + cd ./requests-2.3.0 | |
144 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
145 | + cd .. | |
146 | + rm -rf ./requests-2.3.0 | |
147 | + | |
148 | + tar -zxvf ./voluptuous-0.8.7.tar.gz | |
149 | + cd ./voluptuous-0.8.7 | |
150 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
151 | + cd .. | |
152 | + rm -rf ./voluptuous-0.8.7 | |
153 | + | |
154 | +fi | |
155 | +f_close_section | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 | +++ a/py-packs-liblightbase.sh | |
... | ... | @@ -0,0 +1,88 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +# Instalação das dependências da LIB - liblightbase no python3.2! | |
4 | + | |
5 | +. ./ez_i.sh | |
6 | + | |
7 | +SKIP_ON_V=$1 | |
8 | +if [ -z "$SKIP_ON_V" ] ; then | |
9 | + SKIP_ON_V=0 | |
10 | +fi | |
11 | + | |
12 | +BASE_INST_DIR_V=$2 | |
13 | + | |
14 | +# > ----------------------------------------- | |
15 | +# Informar o diretório base da instalação! | |
16 | + | |
17 | +if [ -z "$BASE_INST_DIR_V" ] ; then | |
18 | + f_open_section | |
19 | + BASE_INST_DIR_V="/usr/local/lb" | |
20 | + | |
21 | + QUESTION_F="Enter the installation directory. | |
22 | + Use empty for \"$BASE_INST_DIR_V\"!" | |
23 | + | |
24 | + f_get_usr_input "$QUESTION_F" 1 | |
25 | + QUESTION_F="" | |
26 | + if [ -n "$GET_USR_INPUT_R" ] ; then | |
27 | + BASE_INST_DIR_V="$GET_USR_INPUT_R/lb" | |
28 | + fi | |
29 | + f_close_section | |
30 | +fi | |
31 | + | |
32 | +# < ----------------------------------------- | |
33 | + | |
34 | +f_open_section | |
35 | + | |
36 | +TITLE_F="Install liblightbase dependencies for python3.2?" | |
37 | + | |
38 | +f_yes_no "$TITLE_F" | |
39 | +TITLE_F="" | |
40 | + | |
41 | +if [ ${YES_NO_R} -eq 1 ] || [ ${SKIP_ON_V} -eq 1 ] ; then | |
42 | + | |
43 | + cd "$SCRIPTDIR_V" | |
44 | + cd ./py-packs-liblightbase | |
45 | + | |
46 | + tar -zxvf ./decorator-3.4.0.tar.gz | |
47 | + cd ./decorator-3.4.0 | |
48 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
49 | + cd .. | |
50 | + rm -rf ./decorator-3.4.0 | |
51 | + | |
52 | + tar -zxvf ./six-1.7.2.tar.gz | |
53 | + cd ./six-1.7.2 | |
54 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
55 | + cd .. | |
56 | + rm -rf ./six-1.7.2 | |
57 | + | |
58 | + tar -zxvf ./ply-3.4.tar.gz | |
59 | + cd ./ply-3.4 | |
60 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
61 | + cd .. | |
62 | + rm -rf ./ply-3.4 | |
63 | + | |
64 | + tar -zxvf ./jsonpath-rw-1.3.0.tar.gz | |
65 | + cd ./jsonpath-rw-1.3.0 | |
66 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
67 | + cd .. | |
68 | + rm -rf ./jsonpath-rw-1.3.0 | |
69 | + | |
70 | + tar -zxvf ./python-dateutil-2.2.tar.gz | |
71 | + cd ./python-dateutil-2.2 | |
72 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
73 | + cd .. | |
74 | + rm -rf ./python-dateutil-2.2 | |
75 | + | |
76 | + tar -zxvf ./requests-2.3.0.tar.gz | |
77 | + cd ./requests-2.3.0 | |
78 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
79 | + cd .. | |
80 | + rm -rf ./requests-2.3.0 | |
81 | + | |
82 | + tar -zxvf ./voluptuous-0.8.7.tar.gz | |
83 | + cd ./voluptuous-0.8.7 | |
84 | + eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" | |
85 | + cd .. | |
86 | + rm -rf ./voluptuous-0.8.7 | |
87 | + | |
88 | +fi | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type