forked from pengovbr/mod-sei-protocolo-integrado
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
129 lines (97 loc) · 6.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.PHONY: .env all help clean dist install restart down destroy up up-background up-foreground config check-super-isalive
-include .env
-include .modulo.env
# Parâmetros de configuração
base = mysql
MODULO_NOME = protocolo-integrado
MODULO_PASTAS_CONFIG = mod-$(MODULO_NOME)
MODULO_PASTA_NOME = $(notdir $(shell pwd))
VERSAO_MODULO := $(shell grep 'define."VERSAO_MODULO_PI"' src/ProtocoloIntegradoIntegracao.php | cut -d'"' -f4)
SEI_SCRIPTS_DIR = dist/sei/scripts/$(MODULO_PASTAS_CONFIG)
SEI_CONFIG_DIR = dist/sei/config/$(MODULO_PASTAS_CONFIG)
SEI_MODULO_DIR = dist/sei/web/modulos/$(MODULO_NOME)
SIP_SCRIPTS_DIR = dist/sip/scripts/$(MODULO_PASTAS_CONFIG)
ARQUIVO_CONFIG_SEI=$(SEI_PATH)/sei/config/ConfiguracaoSEI.php
MSG_ORIENTACAO_CONFIGRACAO=CONFIGURACAO PENDENTE
MODULO_COMPACTADO = mod-sei-$(MODULO_NOME)-v$(VERSAO_MODULO).zip
CMD_INSTALACAO_SEI = echo -ne '$(SEI_DATABASE_USER)\n$(SEI_DATABASE_PASSWORD)\n' | php atualizar_versao_sei.php
CMD_INSTALACAO_SIP = echo -ne '$(SIP_DATABASE_USER)\n$(SIP_DATABASE_PASSWORD)\n' | php atualizar_versao_sip.php
CMD_INSTALACAO_RECURSOS_SEI = echo -ne '$(SIP_DATABASE_USER)\n$(SIP_DATABASE_PASSWORD)\n' | php atualizar_recursos_sei.php
CMD_INSTALACAO_SEI_MODULO = echo -ne '$(SEI_DATABASE_USER)\n$(SEI_DATABASE_PASSWORD)\n' | php sei_atualizar_versao_modulo_protocolo_integrado.php
CMD_INSTALACAO_SIP_MODULO = echo -ne '$(SIP_DATABASE_USER)\n$(SIP_DATABASE_PASSWORD)\n' | php sip_atualizar_versao_modulo_protocolo_integrado.php
CMD_CURL_SUPER_LOGIN = curl -s -L $(SEI_HOST)/sei | grep -q "<input.*txtUsuario.*>"
SUCCESS=\033[0;32m
ERROR=\033[0;31m
WARNING=\033[1;33m
NC=\033[0m
MENSAGEM_AVISO_MODULO = $(ERROR)[ATENÇÃO]:$(NC)$(YELLOW) Necessário configurar a chave de configuração do módulo no arquivo de configuração do SEI (ConfiguracaoSEI.php) $(NC)\n $(YELLOW)'Modulos' => array('ProtocoloIntegradoIntegracao' => 'protocolo-integrado') $(NC)
MENSAGEM_AVISO_ENV = $(ERROR)[ATENÇÃO]:$(NC)$(YELLOW) Configurar parâmetros de autenticação do ambiente de testes do Protocolo Integrado no arquivo .modulo.env $(NC)
all: clean build
dist:
@mkdir -p $(SEI_SCRIPTS_DIR)
@mkdir -p $(SEI_CONFIG_DIR)
@mkdir -p $(SEI_MODULO_DIR)
@mkdir -p $(SIP_SCRIPTS_DIR)
@cp -Rf src/* $(SEI_MODULO_DIR)/
@cp docs/INSTALACAO.md dist/INSTALACAO.md
@cp docs/MIGRACAO.md dist/MIGRACAO.md
@cp docs/Manual_de_Uso.pdf dist/Manual_de_Uso.pdf
@cp docs/changelogs/CHANGELOG-$(VERSAO_MODULO).md dist/NOTAS_VERSAO.md
@mv $(SEI_MODULO_DIR)/scripts/sei_atualizar_versao_modulo_protocolo_integrado.php $(SEI_SCRIPTS_DIR)/
@mv $(SEI_MODULO_DIR)/scripts/sip_atualizar_versao_modulo_protocolo_integrado.php $(SIP_SCRIPTS_DIR)/
@mv $(SEI_MODULO_DIR)/config/ConfiguracaoModProtocoloIntegrado.exemplo.php $(SEI_CONFIG_DIR)/
@rm -rf $(SEI_MODULO_DIR)/config
@rm -rf $(SEI_MODULO_DIR)/scripts
@cd dist/ && zip -r $(MODULO_COMPACTADO) Manual_de_Uso.pdf INSTALACAO.md MIGRACAO.md NOTAS_VERSAO.md sei/ sip/
@rm -rf dist/sei dist/sip dist/INSTALACAO.md dist/MIGRACAO.md dist/Manual_de_Uso.pdf
@echo "Construção do pacote de distribuição finalizada com sucesso"
clean: ## Limpa o diretório contendo arquivos temporários de construção do pacote de distribuição
@rm -rf dist
@rm -rf dist
@echo "Limpeza do diretório de distribuição do realizada com sucesso"
.modulo.env:
cp -n envs/modulo.env .modulo.env
check-super-isalive: ## Target de apoio. Acessa o Super e verifica se esta respondendo a tela de login
@echo ""
@echo "$(WARNING)Aguardando inicialização do ambiente de desenvolvimento...$(NC)"
@for i in `seq 1 10`; do \
echo "Tentativa $$i/10"; \
if $(CMD_CURL_SUPER_LOGIN); then \
echo 'Página de login carregada!' ; \
break ; \
fi; \
sleep 5; \
done; \
if ! $(CMD_CURL_SUPER_LOGIN); then echo '$(ERROR)Ambiente de desenvolvimento não pôde ser carregado corretamente.$(NC)'; exit 1 ; fi;
install: ## Instala e atualiza as tabelas do módulo na base de dados do sistema
docker-compose exec -w /opt/sei/scripts/$(MODULO_PASTAS_CONFIG) httpd bash -c "$(CMD_INSTALACAO_SEI_MODULO)"; true
docker-compose exec -w /opt/sip/scripts/$(MODULO_PASTAS_CONFIG) httpd bash -c "$(CMD_INSTALACAO_SIP_MODULO)"; true
@echo ""
@echo "==================================================================================================="
@if ! grep -q ProtocoloIntegradoIntegracao "$(ARQUIVO_CONFIG_SEI)" ; then echo '$(MENSAGEM_AVISO_MODULO)\n'; fi
@if echo "$(MSG_ORIENTACAO_CONFIGRACAO)" | grep -qw "$(PROTOCOLO_INTEGRADO_LOGIN)" ; then echo '$(MENSAGEM_AVISO_ENV)\n'; fi
@echo ""
@echo "Fim da instalação do módulo"
update: ## Atualiza banco de dados através dos scripts de atualização do sistema
docker-compose run --rm -w /opt/sei/scripts/ httpd bash -c "$(CMD_INSTALACAO_SEI)"; true
docker-compose run --rm -w /opt/sip/scripts/ httpd bash -c "$(CMD_INSTALACAO_SIP)"; true
docker-compose run --rm -w /opt/sip/scripts/ httpd bash -c "$(CMD_INSTALACAO_RECURSOS_SEI)"; true
up: up-backgound ## Inicia ambiente de desenvolvimento local (docker) no endereço http://localhost:8000
up-backgound: .env .modulo.env ## Inicia ambiente de desenvolvimento local (docker) no endereço http://localhost:8000
@if [ ! -f ".env" ]; then cp envs/$(base).env .env; fi
docker-compose up -d
make check-super-isalive
@echo "$(SUCCESS)Ambiente de desenvolvimento iniciado com sucesso: $(SEI_HOST)/sei$(NC)"
up-foreground: .env ## Inicia ambiente de desenvolvimento local (docker) em primeiro plano no endereço http://localhost:8000
docker-compose up
config: ## Configura o ambiente para outro banco de dados (mysql|sqlserver|oracle). Ex: make config base=oracle
@cp -f envs/$(base).env .env
@echo "Ambiente configurado para utilizar a base de dados $(base). (base=[mysql|oracle|sqlserver])"
down: ## Interrompe execução do ambiente de desenvolvimento local em docker
docker-compose down
restart: down up ## Reinicia execução do ambiente de desenvolvimento local em docker
destroy: ## Destrói ambiente de desenvolvimento local, junto com os dados armazenados em banco de dados
docker-compose down --volumes
help:
@echo "Usage: make [target] ... \n"
@grep -E '^[a-zA-Z_-]+[[:space:]]*:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'