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

%define is_rc   0
%define gl_home %{_prefix}/lib/graylog
%if 0%{?suse_version}
%define gl_sysconfdir %{_localstatedir}/adm/fillup-templates/sysconfig.
%define gl_sysconfdir %{_sysconfdir}/sysconfig/
%{!?_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

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

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

Web interface for graylog-server log management system

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


# sles is a bit nagging about version of bytecode so lets make it quiet :)
# 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}
%{__install} -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/%{name}
%{__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})
%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})

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

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

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

%if 0%{?suse_version}
/sbin/chkconfig --add graylog-server

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

%if 0%{?suse_version}

%dir %{gl_home}
%dir %{_sysconfdir}/graylog
%config(noreplace) %{gl_sysconfdir}%name
%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}
%if 0%{?suse_version} >= 1220