File octopus-load-balancer.spec of Package octopus-load-balancer

#
# Copyright (c) 2014 SUSE LINUX Products 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 pkg_name octopuslb

%if 0%{?suse_version} < 1310
%{!?_tmpfilesdir:%global _tmpfilesdir /usr/lib/tmpfiles.d}
%endif

Name:          octopus-load-balancer
Version:       1.14
Release:       0
Summary:       General Purpose TCP Load Balancer
Source:        %{pkg_name}-%{version}.tar.bz2
Source1:       %{pkg_name}.service
Source2:       %{pkg_name}-tmpfile.conf
Source3:       %{pkg_name}.logrotated
# PATCH-FIX-UPSTREAM get/set resource limits
Patch0:        get-set-rlimits.patch
# PATCH-FIX-OPENSUSE fix initrd scripts
Patch1:        octopuslb.initd.patch
URL:           http://sourceforge.net/projects/octopuslb/
Group:         Productivity/Networking/Web/Proxy
License:       GPL-2.0
BuildRoot:     %{_tmppath}/build-%{name}-%{version}
BuildRequires: net-snmp-devel
BuildRequires: gcc make glibc-devel pkgconfig
BuildRequires: autoconf automake libtool
%if 0%{?suse_version} > 1140
BuildRequires: systemd
%{?systemd_requires}
%define has_systemd 1
%else
PreReq:        %insserv_prereq
%endif
Requires:      logrotate 

%description
Octopus is a general purpose TCP load balancer for Linux. It is intended to be
placed between your cache and your application servers but is just as happy
running at the front end of a system.

Octopus boasts the following features;
* runs as a single process giving the fastest possible response times
* a separate process monitors application server health to automatically
  disable/enable servers if their state changes
* four different load balancing algorithms to choose from:
* uses shared memory (SHM) allowing a separate administration binary to
  dynamically reconfigure the running application
* administration binary runs as an interactive shell-type program with usage
  examples and help information
* environment cloning
* ability to place limits on maximum number of connections and maximum
  UNIX-load an application server will handle
* can run many instances of Octopus on the same host
* a SQUID-style configuration file
* can use separate network interfaces for listening port and outbound ports
* logging with 5 levels of verbosity


Authors:
--------
    Alistair Reay <alreay1@gmail.com>

%prep
%setup -q -n %{pkg_name}-%{version}
%patch0 -p1
%patch1 -p1

cp %{S:1} %{pkg_name}.service
cp %{S:2} %{pkg_name}-tmpfile.conf
cp %{S:3} %{pkg_name}.logrotated

%build
%configure
%__make %{?_smp_mflags}

%install
%makeinstall

%__install -d %{buildroot}/%{_sysconfdir}/%{pkg_name}
%__install -d -m 0700 %{buildroot}/var/lib/%{pkg_name}
%__install -d -m 0700 %{buildroot}/var/log/%{pkg_name}

%__mv %{buildroot}/etc/%{pkg_name}.conf %{buildroot}%{_sysconfdir}/%{pkg_name}/
%__install -D -m 0644 %{pkg_name}.logrotated %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}
%if 0%{?has_systemd}
%__install -D -m 0644 %{pkg_name}.service %{buildroot}%{_unitdir}/%{pkg_name}.service
%__install -D -m 0644 %{pkg_name}-tmpfile.conf %{buildroot}%{_tmpfilesdir}/%{pkg_name}.conf
%else
%__install -d %{buildroot}/%{_sbindir}
%__install -D -m 0755 extras/%{pkg_name}.initd  %{buildroot}/%{_initrddir}/%{pkg_name}
%__ln_s %{_initrddir}/%{pkg_name} %{buildroot}/%{_sbindir}/rc%{pkg_name}
%endif

#Fix files-duplicate
%__rm -f COPYRIGHT
%__ln_s	AUTHORS COPYRIGHT

%clean
%__rm -rf "%{buildroot}"

%if 0%{?has_systemd}
%pre
%service_add_pre %{pkg_name}.service
%endif

%post
%if 0%{?has_systemd}
%service_add_post %{pkg_name}.service
%else
%fillup_and_insserv -f %{pkg_name}
%endif

%preun
%if 0%{?has_systemd}
%service_del_preun %{pkg_name}.service
%else
%stop_on_removal %{pkg_name}
%endif

%postun
%if 0%{?has_systemd}
%service_del_postun %{pkg_name}.service
%else
%restart_on_update %{pkg_name}
%{insserv_cleanup}
%endif

%files
%defattr(-,root,root)
%doc AUTHORS CHANGELOG COPYING COPYRIGHT README TODO
%{_sbindir}/octopuslb-admin
%{_sbindir}/octopuslb-server
%attr(0700,root,root) %dir %{_sysconfdir}/%{pkg_name}
%config(noreplace) %{_sysconfdir}/%{pkg_name}/%{pkg_name}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_mandir}/man1/octopuslb-admin.1*
%{_mandir}/man1/octopuslb-server.1*
%{_localstatedir}/lib/%{pkg_name}
%{_localstatedir}/log/%{pkg_name}
%if 0%{?has_systemd}
%{_unitdir}/%{pkg_name}.service
%{_tmpfilesdir}/%{pkg_name}.conf
%else
%{_sbindir}/rc%{pkg_name}
%{_initrddir}/%{pkg_name}
%endif

%changelog
openSUSE Build Service is sponsored by