File graylog-web-interface.spec of Package graylog2-web-interface

#
# spec file for package graylog2-web-interface
#
# 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 is_rc   0
%define gl_home %{_prefix}/lib/graylog
%if 0%{?suse_version}
%define gl_sysconfdir %{_localstatedir}/adm/fillup-templates/sysconfig.
%else
%define gl_sysconfdir %{_sysconfdir}/sysconfig/
%endif
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}

Name:           graylog-web-interface
Version:        1.0.2
Release:        1
%define vertag  %{version}


Summary:        Web interface for graylog-server
License:        Apache-2.0
Group:          System Environment/Daemons

Url:            http://www.graylog.org
Source0:        https://packages.graylog2.org/releases/graylog-web-interface/graylog-web-interface-%{vertag}.tgz
Source1:        init.d-%{name}
Source2:        sysconfig-%{name}
Source3:        web-interface-log.xml
Source4:        service.graylog-web-interface
Source5:        tmpfiles.conf-graylog-web-interface
Source6:        init.d-graylog-web-interface-suse

NoSource:       0
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Requires:       java >= 1.7.0
Requires:       jpackage-utils

# so we do not need to own tmpfiles.d...
%if 0%{?suse_version} >= 1220
BuildRequires:  systemd
%endif

%if 0%{?suse_version}
Requires(pre):  shadow
%else
Requires(post): chkconfig initscripts
Requires(pre):  chkconfig initscripts
Requires(pre):  shadow-utils
%endif

%description
Web interface for graylog-server log management system

%prep
%setup -q -n %{name}-%{vertag}

%build

%install
# sles is a bit nagging about version of bytecode so lets make it quiet :)
export NO_BRP_CHECK_BYTECODE_VERSION=true
# I know we can use -p to create the root directory, but this is more to
# keep track of the required dir
%{__mkdir} -p %{buildroot}%{gl_home}/web
%{__mkdir} -p %{buildroot}%{_sysconfdir}/graylog
cp -rfv {bin,lib} %{buildroot}%{gl_home}/web
rm %{buildroot}%{gl_home}/web/bin/*.bat

# config
cp -rfv conf/graylog-web-interface.conf %{buildroot}%{_sysconfdir}/graylog/web.conf
%{__install} -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/graylog/web-interface-log.xml

# logs
%{__mkdir} -p %{buildroot}%{_localstatedir}/log/graylog

# sysconfig and init
%{__mkdir} -p %{buildroot}%{_sysconfdir}/init.d
%if 0%{?suse_version}
%{__install} -m 755 %{SOURCE6} %{buildroot}%{_sysconfdir}/init.d/%{name}
%else
%{__install} -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/%{name}
%endif
%{__install} -Dm 644 %{SOURCE2} %{buildroot}%{gl_sysconfdir}%{name}
%{__mkdir} -p %{buildroot}%_sbindir
%if 0%{?suse_version}
(cd %{buildroot}%_sbindir ; ln -s %{_sysconfdir}/init.d/%{name} rc%{name})
%endif
%if 0%{?suse_version} >= 1220
%{__mkdir} -p %{buildroot}%_unitdir
%{__install} -Dm 644 %{SOURCE4} %{buildroot}%_unitdir/%{name}.service
%{__install} -Dm 644 %{SOURCE5} %{buildroot}%_tmpfilesdir/%{name}.conf
(cd %{buildroot}%_sbindir && ln -sf /usr/sbin/service rc%{name})
%endif

%{__mkdir} -p %{buildroot}/var/run/graylog

%pre
# create graylog group
if ! getent group graylog >/dev/null; then
        groupadd -r graylog
fi

# create graylog user
if ! getent passwd graylog >/dev/null; then
        useradd -r -g graylog -d %{gl_home} \
            -s /sbin/nologin -c "Party Gorilla" graylog
fi

%post
%if 0%{?suse_version}
%fillup_and_insserv
%restart_on_update
%else
/sbin/chkconfig --add graylog-server
%endif


%preun
%if 0%{?suse_version}
%stop_on_removal
%else
if [ $1 -eq 0 ]; then
  /sbin/service/graylog-web-interface stop >/dev/null 2>&1
  /sbin/chkconfig --del graylog-web-interface
fi
%endif

%postun
%if 0%{?suse_version}
%insserv_cleanup
%restart_on_update
%endif

%files
%defattr(-,root,root,-)
%doc README.md
%dir %{gl_home}
%dir %{_sysconfdir}/graylog
%{gl_home}/web
%{_sysconfdir}/init.d/graylog-web-interface
%config(noreplace) %{gl_sysconfdir}%name
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/graylog/web.conf
%config(noreplace) %{_sysconfdir}/graylog/web-interface-log.xml
%ghost %attr(-,graylog,graylog) %{_localstatedir}/run/graylog
%dir %attr(-,graylog,graylog) %{_localstatedir}/log/graylog
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif
%if 0%{?suse_version} >= 1220
%_unitdir/%{name}.service
%_tmpfilesdir/%{name}.conf
%endif

%changelog