File consul.spec of Package consul
#
# spec file for package consul
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
Name: consul
Version: 1.22.0
Release: 0
Summary: A tool for service discovery, monitoring and configuration
License: Apache-2.0
Group: System/Management
Url: https://github.com/hashicorp/consul
Source0: %{name}_%{version}_linux_amd64.zip
Source1: %{name}-rpmlintrc
Source2: %{name}.service
Source10: %{name}.sysconfig
Source11: %{name}.json
Source20: consul-dns.xml
Source21: consul-grpc.xml
Source22: consul-https.xml
Source23: consul-http.xml
Source24: consul-lan-serf.xml
Source25: consul-rpc.xml
Source26: consul-wan-serf.xml
BuildRequires: unzip
Requires: system-user-consul
%description
A tool for service discovery and configuration, it is distributed, highly
available, and extremely scalable.
%install
cd /tmp
unzip %{SOURCE0}
cp LICENSE.txt %{_builddir}
mkdir -p %{buildroot}%{_bindir}
install -m755 /tmp/%{name} %{buildroot}%{_bindir}/%{name}
install -d -m 0755 %{buildroot}%{_unitdir}
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0644 %{SOURCE10} %{buildroot}%{_fillupdir}/sysconfig.%{name}
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}
install -D -m 0644 %{SOURCE11} %{buildroot}%{_sysconfdir}/%{name}/%{name}.json
install -d -m 750 %{buildroot}%{_localstatedir}/lib/%{name}
# Install firewalld files
install -D -m644 %{SOURCE20} %{buildroot}%{_prefix}/lib/firewalld/services/consul-dns.xml
install -D -m644 %{SOURCE21} %{buildroot}%{_prefix}/lib/firewalld/services/consul-grpc.xml
install -D -m644 %{SOURCE22} %{buildroot}%{_prefix}/lib/firewalld/services/consul-https.xml
install -D -m644 %{SOURCE23} %{buildroot}%{_prefix}/lib/firewalld/services/consul-http.xml
install -D -m644 %{SOURCE24} %{buildroot}%{_prefix}/lib/firewalld/services/consul-lan-serf.xml
install -D -m644 %{SOURCE25} %{buildroot}%{_prefix}/lib/firewalld/services/consul-rpc.xml
install -D -m644 %{SOURCE26} %{buildroot}%{_prefix}/lib/firewalld/services/consul-wan-serf.xml
%pre
%service_add_pre %{name}.service
%post
%{fillup_only -n %{name} %{name}}
%service_add_post %{name}.service
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%defattr(-,root,root,-)
%{_bindir}/consul
%attr(0644,root,root) %{_unitdir}/%{name}.service
%{_fillupdir}/sysconfig.%{name}
%dir %{_prefix}/lib/firewalld
%dir %{_prefix}/lib/firewalld/services
%{_prefix}/lib/firewalld/services/*.xml
%dir %attr(0750,%{name},root) %{_localstatedir}/lib/%{name}
%dir %config(noreplace) %attr(0750,root,%{name}) %{_sysconfdir}/%{name}
%config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/%{name}.json