forked from gb/guia-de-servicos-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
portal-de-servicos.rpmspec
98 lines (79 loc) · 2.78 KB
/
portal-de-servicos.rpmspec
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
# desliga recompressão (quebra JARs)
# - http://stackoverflow.com/questions/9292243/rpmbuild-change-compression-format
# - https://groups.google.com/forum/#!topic/linux.redhat.rpm/TKz6JZHK0ck
%define __os_install_post %{nil}
%define _binary_payload w9.gzdio
%define _user portalservicos
Name: portal-de-servicos
Version: %{version}
Release: 1
Summary: Portal de Servicos
Group: Applications
License: MIT
Vendor: ThoughtWorks, Inc
URL: http://github.com/servicosgovbr/portal-de-servicos
BuildRoot: %{builddir}
Prefix: /opt/%{name}
BuildArchitectures: noarch
# nome antigo do pacote
Obsoletes: guia-de-servicos
Source0: %{_sourcedir}/%{name}-%{version}.jar
Source1: %{_sourcedir}/portal-de-servicos.default.config
%description
Portal de Servicos do Governo Federal do Brasil
%prep
%build
%install
# JAR principal
mkdir -p %{buildroot}/%{prefix}/lib
cp %{SOURCE0} %{buildroot}/%{prefix}/lib/%{name}.jar
# Configurações e variáveis de ambiente
mkdir -p %{buildroot}/etc/sysconfig
cp %{SOURCE1} %{buildroot}/etc/sysconfig/%{name}
cat <<-EOF > %{buildroot}/etc/sysconfig/%{name}-overrides
# Este arquivo sobrescreve variáveis de configuração do Portal de Serviços.
# Para mais informações, veja a documentação em:
#
# http://servicosgovbr.github.io/portal-de-servicos/desenvolvimento/configuracao.html
EOF
mkdir -p %{buildroot}/etc/systemd/system
cat <<-EOF > %{buildroot}/etc/systemd/system/%{name}.service
[Unit]
Description=%{summary}
[Service]
ExecStart=/opt/%{name}/bin/%{name}
User=%{_user}
TimeoutSec=300
EnvironmentFile=/etc/sysconfig/%{name}
EnvironmentFile=/etc/sysconfig/%{name}-overrides
SyslogIdentifier=portal-de-servicos
SyslogLevelPrefix=false
StandardOutput=syslog
StandardError=syslog
WorkingDirectory=/var/lib/%{name}
OOMScoreAdjust=-1000
[Install]
WantedBy=multi-user.target
EOF
mkdir -p %{buildroot}/var/lib/%{name}
# Script para iniciar o processo
mkdir -p %{buildroot}/%{prefix}/bin
cat <<-EOF > %{buildroot}/%{prefix}/bin/%{name}
#!/bin/bash
java \${JAVA_OPTS} -jar %{prefix}/lib/%{name}.jar
EOF
%files
%attr(0755, %{_user}, %{_user}) %{prefix}/bin/%{name}
%attr(0644, %{_user}, %{_user}) %{prefix}/lib/%{name}.jar
%attr(0644, %{_user}, %{_user}) /etc/systemd/system/%{name}.service
%dir %attr(0755, %{_user}, %{_user}) /var/lib/%{name}
%config %attr(0644, %{_user}, %{_user}) /etc/sysconfig/%{name}
%config(noreplace) %attr(0644, %{_user}, %{_user}) /etc/sysconfig/%{name}-overrides
%clean
rm -rf %{buildroot}
%pre
getent group %{_user} >/dev/null || groupadd -r %{_user}
getent passwd %{_user} >/dev/null || \
useradd -r -g %{_user} -d /var/lib/%{name} -s /sbin/nologin \
-c "Usuario para o servico do Portal de Servicos" %{_user}
exit 0