File influxdb-relay.spec of Package influxdb-relay
#
# spec file for package influxdb-relay
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%{!?_tmpfilesdir:%global _tmpfilesdir %{_prefix}/lib/tmpfiles.d}
Name: influxdb-relay
Version: 0+git.1479157637.adaa2ea
Release: 0
Summary: High availability for InfluxDB
License: MIT
Group: Productivity/Databases/Servers
Url: https://github.com/influxdata/influxdb-relay/
Source: %{name}-%{version}.tar.gz
Source1: influxdb-relay.tmpfiles
Source2: influxdb-relay.logrotate
# PATCH-FIX-UPSTREAM influxdb-relay-logging.patch https://github.com/influxdata/influxdb-relay/pull/55
Patch1: influxdb-relay-logging.patch
BuildRequires: go >= 1.6
BuildRequires: golang-github-naoina-toml
BuildRequires: golang-packaging
BuildRequires: influxdb-devel
BuildRequires: systemd-rpm-macros
Requires: logrotate
Requires(post): systemd
Requires(pre): pwdutils
%systemd_requires
%description
InfluxDB relay provides a basic high availability layer for InfluxDB.
%prep
%setup -q
%patch1 -p 1
%build
%{goprep} github.com/influxdata/influxdb-relay
%{gobuild} ...
%install
%{goinstall}
install -p -D -m 644 %{SOURCE1} %{buildroot}/%{_tmpfilesdir}/%{name}.conf
mkdir -p %{buildroot}%{_sysconfdir}/influxdb-relay
mkdir -p %{buildroot}%{_localstatedir}/lib/influxdb-relay
mkdir -p %{buildroot}%{_localstatedir}/log/influxdb-relay
mkdir -p %{buildroot}%{_sbindir}
install -m 0644 sample.toml %{buildroot}%{_sysconfdir}/influxdb-relay/influxdb-relay.conf
install -m 0644 sample_buffered.toml %{buildroot}%{_sysconfdir}/influxdb-relay/influxdb-relay_buffered.conf
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
mkdir -p %{buildroot}%{_unitdir}
install -m 644 scripts/influxdb-relay.service %{buildroot}%{_unitdir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%pre
getent group influxdb-relay >/dev/null || groupadd -r influxdb-relay
getent passwd influxdb-relay >/dev/null || useradd -r -g influxdb-relay \
-d %{_localstatedir}/lib/influxdb-relay \
-s /sbin/nologin \
-c "user for InfluxDB relay" influxdb-relay
%service_add_pre influxdb-relay.service
%preun
%service_del_preun influxdb-relay.service
%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%service_add_post influxdb-relay.service
%postun
%service_del_postun influxdb-relay.service
%files
%defattr(-,root,root,-)
%doc LICENSE README.md
%dir %{_sysconfdir}/influxdb-relay
%config %{_sysconfdir}/influxdb-relay/influxdb-relay.conf
%config %{_sysconfdir}/influxdb-relay/influxdb-relay_buffered.conf
%config %{_sysconfdir}/logrotate.d/%{name}
%{_unitdir}/influxdb-relay.service
%{_sbindir}/rc%{name}
%{_tmpfilesdir}/influxdb-relay.conf
%{_bindir}/influxdb-relay
%attr(0755, influxdb-relay, influxdb-relay) %dir %{_localstatedir}/lib/influxdb-relay
%attr(0750, influxdb-relay, influxdb-relay) %dir %{_localstatedir}/log/influxdb-relay
%changelog