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

#
# spec file for package graylog-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 gl_home %{_prefix}/share/graylog
#
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}
%{!?_rundir: %{expand: %%global _rundir %{_localstatedir}/run}}
#
%if 0%{?suse_version} >= 1230
%bcond_without systemd
%else
%bcond_with  systemd
%endif

Name:           graylog-web-interface
Version:        1.1.1
Release:        0
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/graylog2-web-interface/%{name}-%{version}.tgz
Source1:        %{name}.init.d
Source2:        %{name}.sysconfig
Source3:        %{name}.web-interface-log.xml
Source4:        %{name}.service
Source5:        %{name}.tmpfiles.conf
#Source6:        %%{name}.logrotate
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       java >= 1.7.0
Requires:       jpackage-utils
Requires:       graylog-server = %{version}
Requires:       logrotate
Requires(pre):  shadow
PreReq:         permissions
%if %{with systemd}
BuildRequires:  systemd
%{?systemd_requires}
%else
PreReq:         %insserv_prereq
%endif

%description
Web interface for graylog-server log management system


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


%build


%install
# sles is a bit nagging about version of bytecode so lets make it quiet :)
export NO_BRP_CHECK_BYTECODE_VERSION=true

%{__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

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

# Install dir /var/run/graylog2-web-interface
%{__install} -d -m 0755 %{buildroot}/usr/lib/tmpfiles.d/
%{__install} -m 0644 %{SOURCE5} %{buildroot}/usr/lib/tmpfiles.d/%{name}.conf

# install logrotate file
#install -d -m 755 %%{buildroot}/%%{_sysconfdir}/logrotate.d
#%%{__install} -Dm 644 %%{SOURCE6}  %%{buildroot}%%{_sysconfdir}/logrotate.d/%%name

# install sysconfig file
install -Dm 644 %{SOURCE2} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}

# install init-scripts
mkdir -p %{buildroot}/%{_sbindir}
%if %{with systemd}
install -Dm0644 %{SOURCE4} %{buildroot}/%{_unitdir}/%{name}.service
ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
%else
install -Dm0755 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init.d/%{name}
ln -s %{_sysconfdir}/init.d/%{name} %{buildroot}/%{_sbindir}/rc%{name}
%endif


%pre
%if %{with systemd}
%service_add_pre %{name}.service
%endif
# 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 %{with systemd}
%service_add_post %{name}.service
systemd-tmpfiles --create /usr/lib/tmpfiles.d/%{name}.conf
%endif
%fillup_only


%preun
%if %{with systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif


%postun
%if %{with systemd}
%service_del_postun %{name}.service
%else
%{insserv_cleanup %{name}}
%endif
if [ x"$1" == x"0" ]; then
    # deinstallation of the package
    %if %{with systemd}
      %service_del_postun apache2.service
    %else
      %restart_on_update apache2
    %endif
fi


%files
%defattr(-,root,root,-)
%doc README.md
%dir %{gl_home}
%dir %{_sysconfdir}/graylog
%{gl_home}/web
%defattr(-,root,root,-)
%config(noreplace) %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
%config(noreplace) %{_sysconfdir}/graylog/web.conf
%config(noreplace) %{_sysconfdir}/graylog/web-interface-log.xml
#%%config(noreplace) %%{_sysconfdir}/logrotate.d/%%name
%ghost %attr(-,graylog,graylog) %{_rundir}/graylog
%dir %attr(-,graylog,graylog) %{_localstatedir}/log/graylog
%{_sbindir}/rc%{name}
%if %{with systemd}
%_unitdir/%{name}.service
%_tmpfilesdir/%{name}.conf
%else
%{_sysconfdir}/init.d/%{name}
%endif


%changelog
openSUSE Build Service is sponsored by