File datadome-proxyserver.spec of Package datadome-proxyserver

%define pkg_name datadome-proxyserver

Name:           datadome-proxyserver
Version:        1.1
Release:        0
Summary:        DataDome ProxyServer
License:        custom
Group:          Productivity/Networking/Web/Proxy
Url:            https://www.datadome.co/
Source:         datadome-proxyserver_%{version}.tar.gz
Source1:        datadome-proxyserver.init
Source2:        datadome-proxyserver.suse-init
BuildRequires:  gcc-c++
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  gengetopt
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version}
Requires(post): aaa_base
Requires(preun): aaa_base
Requires(preun): aaa_base
Requires(postun): aaa_base
%else
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
Requires(postun): initscripts
%endif

%description
DataDome Proxy Server

%prep
%setup -q -n %{pkg_name}_%{version}

%build
make %{?_smp_mflags}

%install
install -D -m 0755 datadome_proxyserver %{buildroot}/usr/sbin/datadome_proxyserver
install -D -m 0755 datadome_proxyserver_watchdog.py %{buildroot}/usr/sbin/datadome_proxyserver_watchdog.py
install -D -m 0644 datadome_proxyserver.conf %{buildroot}/etc/datadome/datadome_proxyserver.conf

%if 0%{?suse_version}
install -D -m 0755 %{SOURCE2} %{buildroot}%{_sysconfdir}/init.d/%{pkg_name}
%else
install -D -m 0755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/%{pkg_name}
%endif

%post
/sbin/chkconfig --add %{pkg_name}
/sbin/service %{pkg_name} restart >/dev/null 2>&1 || :


%preun
/sbin/service %{pkg_name} stop >/dev/null 2>&1 || :
/sbin/chkconfig --del %{pkg_name} || :

%pre
%{_sbindir}/groupadd -r datadome &>/dev/null ||:
%{_sbindir}/useradd -g datadome -s /bin/false -r -c "user for datadome" -d /var/lib/datadome datadome &>/dev/null ||:

%files
%defattr(-,root,root)
%dir /etc/datadome
%config(noreplace) /etc/datadome/datadome_proxyserver.conf
/usr/sbin/datadome_proxyserver
/usr/sbin/datadome_proxyserver_watchdog.py
%{_sysconfdir}/init.d/%{pkg_name}

%changelog