File galera-python-clustercheck.spec of Package galera-python-clustercheck
#
# spec file for package galera-python-clustercheck
#
# 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/
#
%define homedir %{_localstatedir}/lib/galera-python-clustercheck
%define configdir %{_sysconfdir}/galera-python-clustercheck
%define user_group galera-python-clustercheck
Name: galera-python-clustercheck
Version: 0.0+git.1564756563.b7bd185
Release: 0
Summary: Galera Python Clustercheck (with twisted)
License: GPL-3.0
Group: Productivity/Databases/Tools
URL: https://github.com/Oneiroi/clustercheck
Source0: %{name}-%{version}.tar.bz2
Source1: galera-python-clustercheck.conf
Source2: galera-python-clustercheck.service
# https://github.com/Oneiroi/clustercheck/pull/35
BuildRequires: systemd-rpm-macros
BuildRequires: python-setuptools
BuildRequires: python-setuptools_scm
Requires(pre): shadow
Requires: python-PyMySQL
Requires: python-Twisted >= 12.0
BuildArch: noarch
%{?systemd_requires}
%description
Galera Python Clustercheck (with twisted).
Runs a service that returns a valid http response (200 or 503) if the cluster
is properally synced.
%prep
%setup -q
%build
SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %{__python2} setup.py build
%install
SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot}
# to be backwards compatible
mv %{buildroot}%{_bindir}/clustercheck %{buildroot}%{_bindir}/%{name}
install -Dpm 0750 -d %{buildroot}%{configdir}
install -Dpm 0750 -d %{buildroot}%{homedir}
install -Dpm 0750 -d %{buildroot}%{_sbindir}
install -Dpm 0640 %{SOURCE1} %{buildroot}%{configdir}/galera-python-clustercheck.conf
install -Dpm 0640 /dev/null %{buildroot}%{configdir}/my.cnf
install -Dpm 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
%pre
getent group %{user_group} >/dev/null || groupadd -r %{user_group}
getent passwd %{user_group} >/dev/null || useradd -r %{user_group} -g %{user_group} -d %{homedir} -s /bin/false -c "Galera Python ClusterCheck"
%service_add_pre %{name}.service
%preun
%service_del_preun %{name}.service
%post
%service_add_post %{name}.service
%postun
%service_del_postun %{name}.service
%files
%doc AUTHORS.txt README.md
%{python_sitelib}/*
%{_bindir}/galera-python-clustercheck
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%dir %attr(0750,%{user_group},%{user_group}) %{homedir}
%dir %attr(-,root,%{user_group}) %{configdir}
%config(noreplace) %attr(-,root,%{user_group}) %{configdir}/galera-python-clustercheck.conf
%ghost %config(noreplace) %attr(-,root,%{user_group}) %{configdir}/my.cnf
%changelog