File zabbix.spec of Package zabbix

#
# spec file for package zabbix
#
# 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/
#

# backport...
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}
%{!?_rundir: %{expand: %%global _rundir %{_localstatedir}/run}}

%if 0%{!?tmpfiles_create:1}
%define tmpfiles_create() \
[ -x /usr/bin/systemd-tmpfiles ] && \
	/usr/bin/systemd-tmpfiles --create %{?*} || : \
%{nil}
%endif

%define zabbix_user   zabbix
%define zabbix_group  zabbix

%define _enable_server --enable-server
%define _enable_proxy --enable-proxy
%define _enable_agent --enable-agent

# globaly defined configure variables
# TODO:which are server specific?
%define _with_openipmi --with-openipmi
#FIXME define _with_java --enable-java
%define _with_ipv6 --enable-ipv6
%define _with_ssh2 --with-ssh2
%define _with_ldap --with-ldap
%define _with_libcurl --with-libcurl
%define _with_jabber --with-jabber
%define _with_net_snmp --with-net-snmp 
%define _with_odbc --with-unixodbc
%define _with_net_snmp --with-net-snmp
%define _with_libxml2 --with-libxml2
# Databases
%define _with_mysql --with-mysql
%define _with_postgresql --with-postgresql
%define _with_sqlite3 --with-sqlite3

%define _with_openssl --with-openssl
#define _with_gnutls  --with-gnutls
#define _with_mbedtls --with-mbedtls

# sle 10 and RHEL4 does not have new enough java sdk... (must be separated sle 10 rpm is a bit picky...
%if 0%{?sles_version} && 0%{?sles_version} <= 10
%undefine _with_java
%endif
%if 0%{?rhel_version} && 0%{?rhel_version} <= 406
%undefine _with_java
%endif
%if 0%{?suse_version}
%define apache2_sysconfdir %(%{_sbindir}/apxs2 -q SYSCONFDIR)
%else
# this should be rhel compatible
%define apache2_sysconfdir %(%{_sbindir}/apxs -q SYSCONFDIR)
%endif

%if 0%{?sles_version} == 11
%define php_minor 3
%endif
%define SuSeFirewall_services_dir /etc/sysconfig/SuSEfirewall2.d/services

#define test_tag 	beta2
#define devel_release 	1
%if 0%{?devel_release:1}
 # Development Release
 %define download_folder ZABBIX%20Latest%20Development
%else
 %if 0%{?test_tag:1}
  # RC Release
  %define download_folder ZABBIX%20Release%20Candidates
 %endif
%endif
%if 0%{!?download_folder:1}
 # Stable release
 %define download_folder ZABBIX%20Latest%20Stable
%endif

Name:           zabbix
Version:        3.2.4
Release:        0
Summary:        Enterprise-class open source distributed monitoring solution
License:        GPL-2.0+
Group:          System/Monitoring
URL:            http://www.zabbix.com
Source0:	http://sourceforge.net/projects/zabbix/files/%{download_folder}/%{version}%{?test_tag}/zabbix-%{version}%{?test_tag}.tar.gz
Source1:        README.SUSE
Patch0:		zabbix_config_on_etc.patch

# Confs
Source10:	zabbix-tmpfiles.conf
Source11:	zabbix-logrotate.in
Source12:	zabbix-apache2x.conf
Source13:       zabbix-java-gateway.sh

## Components
# agentd
Source51:       zabbix-agentd.service
Source52:       zabbix-agentd.init.d
Source53:       zabbix-agentd.firewall
# proxy
Source61:       zabbix-proxy.service
Source62:       zabbix-proxy.init.d
Source63:       zabbix-proxy.firewall
# java-gateway
Source71:       zabbix-java-gateway.service
Source72:       zabbix-java-gateway.init.d
Source73:       zabbix-java-gateway.firewall
# server
Source81:       zabbix-server.service
Source82:       zabbix-server.init.d
Source83:       zabbix-server.firewall

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  pkg-config
BuildRequires:  libxml2-devel
BuildRequires:  update-alternatives
BuildRequires:  fdupes
BuildRequires:  libcurl-devel >= 7.13.1
BuildRequires:  libmysqlclient-devel
%{?_with_openipmi:BuildRequires:  OpenIPMI-devel >= 2}
%{?_with_jabber:BuildRequires:  iksemel-devel}
%{?_with_ssh2:BuildRequires:  libssh2-devel >= 1.0.0}
%{?_with_net_snmp:BuildRequires:  net-snmp-devel}
%{?_with_openssl:BuildRequires:  openssl-devel}
%{?_with_mbedtls:BuildRequires:  polarssl-devel}
%{?_with_gnutls:BuildRequires:  gnutls-devel}
%{?_with_java:BuildRequires:  java-devel >= 1.6.0}
%{?_with_odbc:BuildRequires:  unixODBC-devel}
%{?_with_mysql:BuildRequires:  libmysqlclient-devel}
%{?_with_postgresql:BuildRequires:  postgresql-devel}
%{?_with_sqlite3:BuildRequires:  sqlite-devel >= 3}

%if 0%{?suse_version}
BuildRequires:  apache2-devel
BuildRequires:  help2man
%{?_with_ldap:BuildRequires:  openldap2-devel}
%else
BuildRequires:  httpd-devel
%{?_with_ldap:BuildRequires:  openldap-devel}
%endif
%if 0%{?rhel} >= 6
BuildRequires:	openssl-devel >= 1.0.1
%endif
%if 0%{?_unitdir:1}
BuildRequires:	systemd
%endif

%description
Zabbix is the ultimate enterprise-level software designed for
real-time monitoring of millions of metrics collected from tens of
thousands of servers, virtual machines and network devices.

%prep
%setup -q -n zabbix-%{version}%{?test_tag}
# Suse README
%__cp %{SOURCE1} .
%__cp %{SOURCE13} .

#use /etc for configuration
%patch0 -p1

## TODO: convert all these into ./configure options!

#fix source & config files to respect adapted names
%__sed -i \
	-e 's@/usr/local/etc/@%{_sysconfdir}/@' \
	-e "s@DBUser=root@DBUser=%{zabbix_user}@g" \
	-e "s@^[# ]*DBPassword=.*@DBPassword=%{zabbix_user}@g" \
	-e "s@^[# ]*DBSocket=/tmp/mysql.sock@DBSocket=%{_rundir}/mysql/mysql.sock@g" \
	-e "/^# AlertScriptsPath=/a \\nAlertScriptsPath=%{_libexecdir}/zabbix/alertscripts" \
 	-e '/^# ExternalScripts=/a \\nExternalScripts=%{_libexecdir}/zabbix/externalscripts' \
 	-e '/^# SNMPTrapperFile=.*/a \\nSNMPTrapperFile=%{_localstatedir}/log/snmptrap/snmptrap.log' \
	./ChangeLog ./src/zabbix_agent/zabbix_agentd.c ./conf/*.conf ./src/zabbix_server/server.c ./src/zabbix_proxy/proxy.c ./database/*/data.sql	
	
# change log directory for Java Gateway
%__sed -i \
	-e "s@GW_LOGFILE:=/var/log/zabbix/@GW_LOGFILE:=%{_localstatedir}/log/%{zabbix_user}/@g" \
	-e "s@<file>/tmp/zabbix_@<file>%{_localstatedir}/log/%{zabbix_user}/zabbix_@g" \
	-e "s@ttern>/tmp/zabbix_@ttern>%{_localstatedir}/log/%{zabbix_user}/zabbix_@g" \
	./src/zabbix_java/lib/logback.xml

%__sed -i \
	-e 's@PID_FILE="/tmp/zabbix_@PID_FILE="%{_rundir}/%{zabbix_user}/zabbix_@g' \
 	-e 's|^PID_FILE=.*|PID_FILE="%{_rundir}/%{zabbix_user}/zabbix_java.pid"|g' \
 	-e '/^# TIMEOUT=/a \\nTIMEOUT=3' \
	./src/zabbix_java/settings.sh

##### Fix location of zabbix java gateway location
%__sed -i -r \
	-e 's@^(ZABBIX_JAVA_CONF=.\{ZABBIX_JAVA_CONF:=).*@\1%{_sysconfdir}/zabbix/zabbix_java_gateway.conf}@g' \
	-e "s@GW_PID:=/var/run/zabbix/zabbix-java-gateway.pid@GW_PID:=%{_rundir}/%{zabbix_user}/zabbix-java-gateway.pid@g" \
        -e "s@GW_LOGFILE:=/var/log/zabbix/@GW_LOGFILE:=%{_localstatedir}/log/%{zabbix_user}/@g"\
	zabbix-java-gateway.sh

#fix db content to respect adapted names and suse naming conventions
#fix traceroute command path for global script
for file in database/*/data.sql; do
	%__sed -i \
		-e "s#syslogd#syslog-ng#g" \
		-e "s#Syslogd#Syslog-ng#g" \
		-e "s#httpd#httpd2-prefork#g" \
		-e 's|/usr/bin/traceroute|/usr/sbin/traceroute|' $file
done

##### Fix for date time macros
REF_DATE=$(LANG=C date -r configure +"%%b %%d %%Y")
REF_TIME=$(LANG=C date -r configure +"%%H:%%M:%%S")
sed -i -e "s/__DATE__/\"${REF_DATE}\"/g" -e "s/__TIME__/\"${REF_TIME}\"/g" src/libs/zbxcommon/str.c
#####

%if 0%{?_enable_server:1}
# copy sql files for servers
cat database/mysql/schema.sql > database/mysql/create.sql
cat database/mysql/images.sql >> database/mysql/create.sql
cat database/mysql/data.sql >> database/mysql/create.sql
gzip database/mysql/create.sql

cat database/postgresql/schema.sql > database/postgresql/create.sql
cat database/postgresql/images.sql >> database/postgresql/create.sql
cat database/postgresql/data.sql >> database/postgresql/create.sql
gzip database/postgresql/create.sql

cat database/sqlite3/schema.sql > database/sqlite3/create.sql
cat database/sqlite3/images.sql >> database/sqlite3/create.sql
cat database/sqlite3/data.sql >> database/sqlite3/create.sql
gzip database/sqlite3/create.sql

# remove font file, use it from SUSE
rm -f frontends/php/fonts/DejaVuSans.ttf
%endif

%if 0%{?_enable_proxy:1}
# sql files for proxyes
gzip database/mysql/schema.sql
gzip database/postgresql/schema.sql
gzip database/sqlite3/schema.sql
%endif

%build

for _with_db in %{?_with_mysql} %{?_with_postgresql} %{?_with_sqlite3}; do
	dbname=${_with_db#--with-}
	## Do we really need full rebuild?
	[ -e src/zabbix_server/zabbix_server ] && %__make clean
	%configure \
		%{?_enable_proxy} \
		%{?_enable_server} \
		%{?_enable_agent} \
		--sysconfdir=%{_sysconfdir}/zabbix \
		%{?_with_openipmi} \
		%{?_with_java} \
		%{?_with_ipv6} \
		%{?_with_ssh2} \
		%{?_with_ldap} \
		%{?_with_openssl} \
		%{?_with_mbedtls} \
		%{?_with_gnutls} \
		%{?_with_odbc} \
		%{?_with_libcurl} \
		%{?_with_jabber} \
		%{?_with_openipmi} \
		%{?_with_net_snmp} \
		%{?_with_vmware} \
		%{?_with_libxml2} \
		${_with_db}
	
	%__make %{?_smp_mflags}
	%__cp src/zabbix_server/zabbix_server src/zabbix_server/zabbix_server_${dbname}
	help2man -N -o zabbix_server_${dbname}.1 ./src/zabbix_server/zabbix_server_${dbname}
	%__cp src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_${dbname}
	help2man -N -o zabbix_proxy_${dbname}.1 ./src/zabbix_proxy/zabbix_proxy_${dbname}
done
for prog in src/zabbix_get/zabbix_get src/zabbix_agent/zabbix_agentd src/zabbix_sender/zabbix_sender; do
	help2man -N -o $(basename ${prog}).1 ./${prog}
done
%__rm src/zabbix_server/zabbix_server
%__rm src/zabbix_proxy/zabbix_proxy

%install

# install
%__make DESTDIR=$RPM_BUILD_ROOT install

# install necessary directories
%__mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/zabbix

# update-alternatives handling for manual pages
%__install -d -m 0755 %{buildroot}%{_sysconfdir}/alternatives

# install proxy
%if 0%{?_enable_proxy:1}
	%__rm $RPM_BUILD_ROOT%{_sbindir}/zabbix_proxy
	%__install -m 0755 -p src/zabbix_proxy/zabbix_proxy_* $RPM_BUILD_ROOT%{_sbindir}/
	%__install -Dm 0644 zabbix_proxy_*.1 %{buildroot}%{_mandir}/man1/
	touch -r /bin/true %{buildroot}%{_sysconfdir}/alternatives/zabbix_proxy 
	touch -r /etc/passwd %{buildroot}%{_sysconfdir}/alternatives/zabbix_proxy.1%{?ext_man} 
	%__ln_s -f %{_sysconfdir}/alternatives/zabbix_proxy.1%{?ext_man} %{buildroot}%{_mandir}/man1/zabbix_proxy.1
	%__ln_s -f %{_sysconfdir}/alternatives/zabbix_proxy %{buildroot}%{_sbindir}/zabbix_proxy
	touch -r /bin/true %{buildroot}%{_sysconfdir}/alternatives/zabbix_proxy 
%endif

# install server
%if 0%{?_enable_server:1}
	%__rm $RPM_BUILD_ROOT%{_sbindir}/zabbix_server
	%__install -m 0755 -p src/zabbix_server/zabbix_server_* $RPM_BUILD_ROOT%{_sbindir}/
	%__install -Dm 0644 zabbix_server_*.1 %{buildroot}%{_mandir}/man1/
	touch -r /bin/true %{buildroot}%{_sysconfdir}/alternatives/zabbix_server
	touch -r /etc/passwd %{buildroot}%{_sysconfdir}/alternatives/zabbix_server.1%{?ext_man}
	%__ln_s -f %{_sysconfdir}/alternatives/zabbix_server.1%{?ext_man} %{buildroot}%{_mandir}/man1/zabbix_server.1
	%__ln_s -f %{_sysconfdir}/alternatives/zabbix_server %{buildroot}%{_sbindir}/zabbix_server
	touch -r /bin/true %{buildroot}%{_sysconfdir}/alternatives/zabbix_server

	#install the php frontend
	%__mkdir_p %{buildroot}%{_datadir}/zabbix
	%__cp -r frontends/php/* %{buildroot}%{_datadir}/zabbix
	# remove .htaccess files as access rules are moved to zabbix.conf
	find %{buildroot}%{_datadir}/zabbix -name .htaccess -delete
	find %{buildroot}%{_datadir}/zabbix -name '*.orig' -delete
	
	# install frontend configuration files
	mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/web
	touch $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/web/zabbix.conf.php
	mv $RPM_BUILD_ROOT%{_datadir}/zabbix/conf/maintenance.inc.php $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/web/

 	%__install -Dm 0644 %{SOURCE12} %{buildroot}%{apache2_sysconfdir}/conf.d/zabbix.conf
%endif

%if 0%{?_enable_agent:1}
%__install -Dm 0644 zabbix_agentd.1 %{buildroot}%{_mandir}/man1/
%endif

# Manual pages # DOES THEM BELONG TO ANY server/proxy/agent?
%__install -Dm 0644 zabbix_get.1 %{buildroot}%{_mandir}/man1/
%__install -Dm 0644 zabbix_sender.1 %{buildroot}%{_mandir}/man1/

#install java gateway files
%if 0%{?_with_java:1}

mv $RPM_BUILD_ROOT%{_sbindir}/zabbix_java $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway
mv $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway/lib/logback.xml $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_java_gateway_logback.xml
rm $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway/settings.sh
rm $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway/startup.sh
rm $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway/shutdown.sh
rm $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway/shutdown.sh
rm $RPM_BUILD_ROOT%{_datadir}/zabbix-java-gateway/lib/logback-console.xml
install -m 0755 -p zabbix-java-gateway.sh $RPM_BUILD_ROOT%{_sbindir}/zabbix_java_gateway

#install java gateway files
%__install -dm 0755 %{buildroot}%{_prefix}/lib/zabbix-java-gateway
%__cp -r src/zabbix_java/lib/*.jar %{buildroot}%{_prefix}/lib/zabbix-java-gateway
%__install -Dm 0644 src/zabbix_java/bin/zabbix-java-gateway-%{version}%{?rclevel}.jar %{buildroot}%{_prefix}/lib/zabbix-java-gateway/zabbix-java-gateway-%{version}%{?rclevel}.jar
%__install _m 0644 src/zabbix_java/settings.sh %{buildroot}%{_sysconfdir}/zabbix/zabbix_java_gateway.conf
%__install _m 0644 src/zabbix_java/lib/logback.xml %{buildroot}%{_sysconfdir}/zabbix/zabbix_java_gateway_log.xml
%endif

# install scripts and modules directories
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/zabbix
%if 0%{?_enable_server:1}
mv $RPM_BUILD_ROOT%{_datadir}/zabbix/alertscripts $RPM_BUILD_ROOT%{_libexecdir}/zabbix
%endif
mv $RPM_BUILD_ROOT%{_datadir}/zabbix/externalscripts $RPM_BUILD_ROOT%{_libexecdir}/zabbix
mkdir -p $RPM_BUILD_ROOT%{_libdir}/zabbix/modules

install -dm 755 $RPM_BUILD_ROOT%{_docdir}/zabbix-agentd-%{version}
install -m 0644 conf/zabbix_agentd/userparameter_examples.conf $RPM_BUILD_ROOT%{_docdir}/zabbix-agentd-%{version}
install -m 0644 conf/zabbix_agentd/userparameter_mysql.conf $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_agentd.conf.d


mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/tmpfiles.d/
for component in %{?_enable_agent:agentd} %{?_enable_server:server} %{?_enable_proxy:proxy}; do
	install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_$component.conf.d/
	%__sed -i \
		-e '/^# PidFile=/a \\nPidFile=%{_rundir}/%{zabbix_user}/zabbix_'$component'.pid' \
		-e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{zabbix_user}/zabbix_'$component'.log|g' \
		-e '/^# LogFileSize=.*/a \\nLogFileSize=0' \
		-e '/^# Include=$/a \\nInclude=%{_sysconfdir}/zabbix/zabbix_'$component'.conf.d/*.conf' \
 	$RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_$component.conf

	# install logrotate configuration files
	%__sed \
			-e "s|@@@COMPONENT@@@|$component|g" \
			-e "s|@@@USER@@@|%zabbix_user|g" \
			-e "s|@@@COMPONENT@@@|%zabbix_group|g" \
		%{SOURCE11} > $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-$component
		
	# install systemd-tmpfiles conf
	echo "d %{_rundir}/%{zabbix_user} 0755 %{zabbix_user} %{zabbix_group} -" > %{buildroot}%{_prefix}/lib/tmpfiles.d/zabbix-$component.conf
done

# SystemD
%if 0%{?_unitdir:1}
for component_file in \
		%{?_enable_agent:"agentd:%{SOURCE51}"} \
		%{?_enable_proxy:"proxy:%{SOURCE61}"} \
		%{?_with_java:"java_gateway:%{SOURCE71}"} \
		%{?_enable_server:"server:%{SOURCE81}"}; do
	component=$(cut -d: -f1 <<<"$component_file")
	file=$(cut -d: -f2- <<<"$component_file")
	%__install -Dm 0644 -p "$file" $RPM_BUILD_ROOT%{_unitdir}/zabbix-$component.service
	%__install -dm 0755 %{buildroot}/%{_unitdir}/zabbix-$component.service.requires
  %if 0%{?suse_version:1}
	%__ln_s -f service %{buildroot}%{_sbindir}/rczabbix-$component
  %endif
done
%else
# SysV
for component_file in \
		%{?_enable_agent:"agentd:%{SOURCE52}"} \
		%{?_enable_proxy:"proxy:%{SOURCE62}"} \
		%{?_with_java:"java_gateway:%{SOURCE72}"} \
		%{?_enable_server:"server:%{SOURCE82}"}; do
	component=$(cut -d: -f1 <<<"$component_file")
	file=$(cut -d: -f2- <<<"$component_file")
	%__install -Dm 0644 -p "$file" $RPM_BUILD_ROOT%{_initddir}/init.d/zabbix-$component
  %if 0%{?suse_version:1}
	%__ln_s %{_initddir}/zabbix-$component %{buildroot}%{_sbindir}/rczabbix-$component
  %endif
done  
%endif

# FIXME if the java gateway is not being built, remove the orphan files
%if ! 0%{?with_java:1}
	rm -f $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_java_gateway.conf
%endif

#install firewall description files
%if 0%{?suse_version} > 1020
	%__install -d 0755 %{buildroot}%{SuSeFirewall_services_dir}
	for component_file in \
			%{?_enable_agent:"agentd:%{SOURCE52}"} \
			%{?_enable_proxy:"proxy:%{SOURCE62}"} \
			%{?_with_java:"java_gateway:%{SOURCE72}"} \
			%{?_enable_server:"server:%{SOURCE82}"}; do
		component=$(cut -d: -f1 <<<"$component_file")
		file=$(cut -d: -f2- <<<"$component_file")
		%__install -m 0755 "$file" %{buildroot}%{SuSeFirewall_services_dir}/zabbix-$component
	done
%endif

#create directory structure
%__install -d %{buildroot}%{_localstatedir}/log/%{zabbix_user}
%__install -d %{buildroot}%{_rundir}/%{zabbix_user}

%if 0%{?suse_version:1}
	%fdupes %{buildroot}
	# SLE 11 does not like new java bytecode so just ignore that check
	export NO_BRP_CHECK_BYTECODE_VERSION=true
%endif

touch %{buildroot}%_sysconfdir/alternatives/zabbix-web-font
%__ln_s -f %{_sysconfdir}/alternatives/zabbix-web-font %{buildroot}%{_datadir}/zabbix/fonts/graphfont.ttf


%if 0%{?_enable_agent:1}

%package agentd
Requires(pre):  pwdutils %insserv_prereq %fillup_prereq
Summary:        The Zabbix agent
Group:          System/Monitoring
Requires:		logrotate
Requires(pre):		/usr/sbin/useradd
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(preun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Obsoletes:		zabbix < %{version}

%description agentd
The Zabbix agent monitors local resources and relays information to the server.

%pre agentd
%if 0%{?_unitdir:1}
%service_add_pre zabbix-agentd.service
%endif
%{_bindir}/getent group %{zabbix_group} >/dev/null || %{_sbindir}/groupadd -r %{zabbix_group} || :
%{_bindir}/getent passwd %{zabbix_user} >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/%{zabbix_user} -s /bin/false -c "Zabbix Monitoring Daemon" -g %{zabbix_group} %{zabbix_user} || :

%post agentd
%if 0%{?_unitdir:1}
%service_add_post zabbix-agentd.service
%tmpfiles_create %{_prefix}/lib/tmpfiles.d/zabbix-agentd.conf
%else
%fillup_and_insserv -f zabbix-agentd
%endif

%preun agentd
%if 0%{?_unitdir:1}
%service_del_preun zabbix-agentd.service
%else
%stop_on_removal zabbix-agentd
%endif

%postun agentd
%if 0%{?_unitdir:1}
%service_del_postun zabbix-agentd.service
%else
%restart_on_update zabbix-agentd
%insserv_cleanup
%endif

%files agentd
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README
%dir %{_sysconfdir}/zabbix/zabbix_agentd.conf.d
%config(noreplace) %attr(0640, root, %{zabbix_group}) %{_sysconfdir}/zabbix/zabbix_agentd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-agentd
%config(noreplace) %{_sysconfdir}/zabbix/zabbix_agentd.conf.d/userparameter_mysql.conf
%if 0%{?_unitdir:1}
%{_unitdir}/zabbix-agentd.service
%{_prefix}/lib/tmpfiles.d/zabbix-agentd.conf
%else
%{_initddir}/zabbix-agentd
%endif
%dir %{_sysconfdir}/zabbix
%if 0%{?suse_version} > 1020
%config %{SuSeFirewall_services_dir}/zabbix-agentd
%endif
%{_sbindir}/rczabbix-agentd
%{_sbindir}/zabbix_agentd
%attr(0750,root,%{zabbix_group}) %dir %{_localstatedir}/log/%{zabbix_user}
%ghost %attr(0750,root,%{zabbix_group}) %dir %{_rundir}/%{zabbix_user}
%{_mandir}/man1/zabbix_agentd.1%{?ext_man}
%{_mandir}/man8/zabbix_agentd.8%{?ext_man}
%doc %{_docdir}/zabbix-agentd-%{version}
%dir %{_prefix}/lib/zabbix

%package get
Summary:			Zabbix Get
Group:				System/Monitoring

%description get
Zabbix get command line utility

%files get
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
%{_bindir}/zabbix_get
%{_mandir}/man1/zabbix_get.1%{?ext_man}


%package sender
Summary:			Zabbix Sender
Group:				System/Monitoring

%description sender
Zabbix sender command line utility

%files sender
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
%{_bindir}/zabbix_sender
%{_mandir}/man1/zabbix_sender.1%{?ext_man}

%endif #_enable_agent


%if 0%{?_enable_server:1}

%package server
Requires:	logrotate
Requires:       zabbix_server_binary = %{version}-%{release}
Requires(pre):  pwdutils %insserv_prereq %fillup_prereq
Summary:        The Zabbix server
Group:          System/Monitoring

%description server
The Zabbix server component.

%pre server
%if 0%{?_unitdir:1}
%service_add_pre zabbix-server.service
%endif
%{_bindir}/getent group %{zabbix_group} >/dev/null || %{_sbindir}/groupadd -r %{zabbix_group} || :
%{_bindir}/getent passwd %{zabbix_user} >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/%{zabbix_user} -s /bin/false -c "Zabbix Server Daemon" -g %{zabbix_group} %{zabbix_user} || :

%post server
%if 0%{?_unitdir:1}
%service_add_post zabbix-server.service
%tmpfiles_create %{_prefix}/lib/tmpfiles.d/zabbix-server.conf
%else
%fillup_and_insserv -f zabbix-server
%endif

%preun server
%if 0%{?_unitdir:1}
%service_del_preun zabbix-server.service
%else
%stop_on_removal zabbix-server
%endif

%postun server
%if 0%{?_unitdir:1}
%service_del_postun zabbix-server.service
%else
%restart_on_update zabbix-server
%insserv_cleanup
%endif

%files server
%defattr(-,root,root)
%doc AUTHORS ChangeLog upgrades/dbpatches
%dir %{_sysconfdir}/zabbix
%config(noreplace) %attr(0640, root, %{zabbix_group}) %{_sysconfdir}/zabbix/zabbix_server.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-server
%if 0%{?suse_version} > 1020
%config %{SuSeFirewall_services_dir}/zabbix-server
%endif
%{_sbindir}/rczabbix-server
%attr(0750,root,%{zabbix_group}) %dir %{_localstatedir}/log/%{zabbix_user}
%ghost %attr(0750,root,%{zabbix_group}) %dir %{_rundir}/%{zabbix_user}
%{_mandir}/man8/zabbix_server.8%{?ext_man}
%if 0%{?_unitdir:1}
%{_unitdir}/zabbix-server.service
%{_unitdir}/zabbix-server.service.requires
%{_prefix}/lib/tmpfiles.d/zabbix-server.conf
%else
%{_initddir}/zabbix-server
%endif
%ghost %{_sysconfdir}/alternatives/zabbix_server
%ghost %{_sysconfdir}/alternatives/zabbix_server.1%{?ext_man}

%if 0%{?_with_mysql:1}
%package server-mysql
Provides:       	%{name} = %{version}-%{release}
Provides:       	zabbix_server_binary = %{version}-%{release}
Requires:       	%{name}-server = %{version}-%{release}
Requires(post): 	update-alternatives
Requires(postun): 	update-alternatives
Summary:        	Zabbix server with MySQL support
Group:          	System/Monitoring
Requires:		fping
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Provides:		zabbix-server = %{version}-%{release}
Provides:		zabbix-server-implementation = %{version}-%{release}
Obsoletes:		zabbix < %{version}

%description server-mysql
The Zabbix server compiled with MySQL support.


%post server-mysql
%{_sbindir}/update-alternatives --install %{_sbindir}/zabbix_server zabbix_server %{_sbindir}/zabbix_server_mysql 11 \
	--slave %{_mandir}/man1/zabbix_server.1%{?ext_man} zabbix_server.1%{?ext_man} %{_mandir}/man1/zabbix_server_mysql.1%{?ext_man}

%preun server-mysql
if [ "$1" = 0 ] ; then
	%{_sbindir}/update-alternatives --remove zabbix_server %{_sbindir}/zabbix_server_mysql
fi

%files server-mysql
%defattr(-,root,root)
%{_sbindir}/zabbix_server_mysql
%if 0%{?suse_version} >= 1130
%ghost %_sysconfdir/alternatives/zabbix_server
%ghost %_sysconfdir/alternatives/zabbix_server.1%{?ext_man}
%endif
%{_sbindir}/zabbix_server
%{_mandir}/man1/zabbix_server.1%{?ext_man}
%{_mandir}/man1/zabbix_server_mysql.1%{?ext_man}
%endif
%doc database/mysql/create.sql.gz

%if 0%{?_with_postgresql:1}
%package server-postgresql
Provides:       	%{name} = %{version}-%{release}
Provides:       	zabbix_server_binary = %{version}-%{release}
Requires:       	%{name}-server = %{version}-%{release}
Requires(post): 	update-alternatives
Requires(postun): 	update-alternatives
Summary:        	Zabbix server with PostgreSQL support
Group:          	System/Monitoring
Requires:		fping
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Provides:		zabbix-server = %{version}-%{release}
Provides:		zabbix-server-implementation = %{version}-%{release}
Obsoletes:		zabbix < %{version}

%description server-postgresql
The Zabbix server compiled with PostgreSQL support.


%post server-postgresql
%{_sbindir}/update-alternatives --install %{_sbindir}/zabbix_server zabbix_server %{_sbindir}/zabbix_server_postgresql 11 \
	--slave %{_mandir}/man1/zabbix_server.1%{?ext_man} zabbix_server.1%{?ext_man} %{_mandir}/man1/zabbix_server_postgresql.1%{?ext_man}

%preun server-postgresql
if [ "$1" = 0 ] ; then
	%{_sbindir}/update-alternatives --remove zabbix_server %{_sbindir}/zabbix_server_postgresql
fi

%files server-postgresql
%defattr(-,root,root)
%{_sbindir}/zabbix_server_postgresql
%if 0%{?suse_version} >= 1130
%ghost %_sysconfdir/alternatives/zabbix_server
%ghost %_sysconfdir/alternatives/zabbix_server.1%{?ext_man}
%endif
%{_sbindir}/zabbix_server
%{_mandir}/man1/zabbix_server.1%{?ext_man}
%{_mandir}/man1/zabbix_server_postgresql.1%{?ext_man}
%doc database/postgresql/create.sql.gz

%endif

%if 0%{?_with_sqlite3:1}
%package server-sqlite3
Provides:       %{name} = %{version}-%{release}
Provides:       zabbix_server_binary = %{version}-%{release}
Requires:       %{name}-server = %{version}-%{release}
Requires(post): update-alternatives
Requires(postun): update-alternatives
Summary:        Zabbix server with SQLite support
Group:          System/Monitoring

%description server-sqlite3
The Zabbix server compiled with SQLite support.

%preun server-sqlite3
if [ "$1" = 0 ] ; then
	%{_sbindir}/update-alternatives --remove zabbix_server %{_sbindir}/zabbix_server_sqlite3
fi

%post server-sqlite3
%{_sbindir}/update-alternatives --install %{_sbindir}/zabbix_server zabbix_server %{_sbindir}/zabbix_server_sqlite3 10 \
	--slave %{_mandir}/man1/zabbix_server.1%{?ext_man} zabbix_server.1%{?ext_man} %{_mandir}/man1/zabbix_server_sqlite3.1%{?ext_man}

%files server-sqlite3
%defattr(-,root,root)
%{_sbindir}/zabbix_server_sqlite3
%if 0%{?suse_version} >= 1130
%ghost %_sysconfdir/alternatives/zabbix_server
%ghost %_sysconfdir/alternatives/zabbix_server.1%{?ext_man}
%endif
%{_sbindir}/zabbix_server
%{_mandir}/man1/zabbix_server.1%{?ext_man}
%{_mandir}/man1/zabbix_server_sqlite3.1%{?ext_man}
%endif
%doc database/sqlite3/create.sql.gz

%package web
Summary:        	Zabbix web frontend (php)
Group:          	Productivity/Networking/Web/Frontends
Requires:       	php5%{?php_minor}
Requires:       	php5%{?php_minor}-bcmath
Requires:       	php5%{?php_minor}-ctype
Requires:       	php5%{?php_minor}-gd
Requires:       	php5%{?php_minor}-ldap
Requires:       	php5%{?php_minor}-mbstring
Requires:       	php5%{?php_minor}-sockets
BuildArch:		noarch
%if 0%{?_unitdir:1}
Requires:		httpd
Requires:		php >= 5.4
Requires:		php-gd
Requires:		php-bcmath
Requires:		php-mbstring
Requires:		php-xml
Requires:		php-ldap
%endif
%if 0%{?sles_version} == 11
Requires:		dejavu
%define ttf_fontdir     /usr/share/fonts/truetype
%else
Requires:		dejavu-fonts
BuildRequires:		dejavu-fonts
BuildRequires:		fontpackages-devel
%endif
Requires:		zabbix-web-database = %{version}-%{release}
Requires(post):		%{_sbindir}/update-alternatives
Requires(preun):	%{_sbindir}/update-alternatives
Obsoletes:		zabbix-phpfrontend

%description web
The Zabbix PHP frontend allows easy access via standard web browsers.

NOTE: You still have to install the PHP package which contains your db driver!

%post web
/usr/sbin/update-alternatives --install %{_datadir}/zabbix/fonts/graphfont.ttf \
	zabbix-web-font %{_ttfontsdir}/DejaVuSans.ttf 10
:

%preun web
if [ "$1" = 0 ]; then
/usr/sbin/update-alternatives --remove zabbix-web-font \
	%{_ttfontsdir}/DejaVuSans.ttf
fi
:

%files web
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README README.SUSE
%dir %attr(0750,wwwrun,www) %{_sysconfdir}/zabbix/web
%ghost %attr(0644,wwwrun,www) %config(noreplace) %{_sysconfdir}/zabbix/web/zabbix.conf.php
%config(noreplace) %{_sysconfdir}/zabbix/web/maintenance.inc.php
%if 0%{?rhel:1}
%config(noreplace) %{_sysconfdir}/httpd/conf.d/zabbix.conf
%else
%config(noreplace) %{apache2_sysconfdir}/conf.d/zabbix.conf
%endif
%dir %{apache2_sysconfdir}
%dir %{apache2_sysconfdir}/conf.d
%{_datadir}/zabbix/fonts/graphfont.ttf
%{_datadir}/zabbix
%ghost %{_sysconfdir}/alternatives/graphfont.ttf
%ghost %{_sysconfdir}/alternatives/zabbix-web-font

%if 1

%package web-japanese
Summary:		Japanese font settings for frontend
Group:			Applications/Internet
BuildArch:		noarch
Requires:		zabbix-web = %{version}-%{release}
Requires(post):		%{_sbindir}/update-alternatives
Requires(preun):	%{_sbindir}/update-alternatives
%if 0%{?sles_version} == 11
Requires:		IPAGothic
BuildRequires:		IPAGothic
%define japanese_font	ipag.ttf
%else
Requires:		vlgothic-fonts
BuildRequires:		vlgothic-fonts
%define japanese_font	VL-PGothic-Regular.ttf
%endif


%description web-japanese
Japanese font configuration for Zabbix web frontend

%post web-japanese
/usr/sbin/update-alternatives --install %{_datadir}/zabbix/fonts/graphfont.ttf \
	zabbix-web-font %{_ttfontsdir}/%{japanese_font} 20
:

%preun web-japanese
if [ "$1" = 0 ]; then
/usr/sbin/update-alternatives --remove zabbix-web-font \
	%{_ttfontsdir}/%{japanese_font}
fi
:

%files web-japanese
%defattr(-,root,root,-)
%ghost %_sysconfdir/alternatives/zabbix-web-font
%ghost %_sysconfdir/alternatives/graphfont.ttf
%{_datadir}/zabbix/fonts/graphfont.ttf

%endif

%endif #_enable_server


%if 0%{?_enable_proxy:1}
%package proxy
Requires:       zabbix_proxy_binary = %{version}-%{release}
Requires:	logrotate
Requires(pre):  pwdutils %insserv_prereq %fillup_prereq
Summary:        The Zabbix proxy
Group:          System/Monitoring

%description proxy
The Zabbix proxy component.

%pre proxy
%if 0%{?_unitdir:1}
%service_add_pre zabbix-proxy.service
%endif
%{_bindir}/getent group %{zabbix_group} >/dev/null || %{_sbindir}/groupadd -r %{zabbix_group} || :
%{_bindir}/getent passwd %{zabbix_user} >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/%{zabbix_user} -s /bin/false -c "Zabbix Proxy Daemon" -g %{zabbix_group} %{zabbix_user} || :

%post proxy
%if 0%{?_unitdir:1}
%service_add_post zabbix-proxy.service
%tmpfiles_create %{_prefix}/lib/tmpfiles.d/zabbix-proxy.conf
%else
%fillup_and_insserv -f zabbix-proxy
%endif

%preun proxy
%if 0%{?_unitdir:1}
%service_del_preun zabbix-proxy.service
%else
%stop_on_removal zabbix-proxy
%endif

%postun proxy
%if 0%{?_unitdir:1}
%service_del_postun zabbix-proxy.service
%else
%restart_on_update zabbix-proxy
%insserv_cleanup
%endif

%files proxy
%defattr(-,root,root)
%{_sbindir}/rczabbix-proxy
%dir %{_sysconfdir}/zabbix
%config(noreplace) %attr(0640, root, %{zabbix_group}) %{_sysconfdir}/zabbix/zabbix_proxy.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-proxy
%if 0%{?suse_version} > 1020
%config %{SuSeFirewall_services_dir}/zabbix-proxy
%endif
%attr(0750,root,%{zabbix_group}) %dir %{_localstatedir}/log/%{zabbix_user}
%ghost %attr(0750,root,%{zabbix_group}) %dir %{_rundir}/%{zabbix_user}
%{_mandir}/man8/zabbix_proxy.8%{?ext_man}
%if 0%{?_unitdir:1}
%{_unitdir}/zabbix-proxy.service
%{_unitdir}/zabbix-proxy.service.requires
%{_prefix}/lib/tmpfiles.d/zabbix-proxy.conf
%else
%{_initddir}/zabbix-proxy
%endif
%ghost %{_sysconfdir}/alternatives/zabbix_proxy
%ghost %{_sysconfdir}/alternatives/zabbix_proxy.1%{?ext_man}

%if 0%{?_with_mysql:1}

%package proxy-mysql
Summary:		Zabbix proxy for MySQL or MariaDB database
Group:          	System/Monitoring
Provides:       	%{name} = %{version}-%{release}
Provides:       	zabbix_proxy_binary = %{version}-%{release}
Provides:		zabbix-proxy = %{version}-%{release}
Provides:		zabbix-proxy-implementation = %{version}-%{release}
Obsoletes:		zabbix < %{version}
Requires:		fping
Requires:       	%{name}-proxy = %{version}-%{release}
Requires(post): 	update-alternatives
Requires(postun): 	update-alternatives
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Conflicts:		zabbix-proxy-postgresql
Conflicts:		zabbix-proxy-sqlite3

%description proxy-mysql
Zabbix proxy with MySQL or MariaDB database support.

%preun proxy-mysql
if [ "$1" = 0 ] ; then
	%{_sbindir}/update-alternatives --remove zabbix_proxy %{_sbindir}/zabbix_proxy_mysql
fi

%post proxy-mysql
%{_sbindir}/update-alternatives --install %{_sbindir}/zabbix_proxy zabbix_proxy %{_sbindir}/zabbix_proxy_mysql 11 \
	--slave %{_mandir}/man1/zabbix_proxy.1%{?ext_man} zabbix_proxy.1%{?ext_man} %{_mandir}/man1/zabbix_proxy_mysql.1%{?ext_man}

%files proxy-mysql
%defattr(-,root,root)
%{_sbindir}/zabbix_proxy_mysql
%if 0%{?suse_version} >= 1130
%ghost %_sysconfdir/alternatives/zabbix_proxy
%ghost %_sysconfdir/alternatives/zabbix_proxy.1%{?ext_man}
%endif
%{_sbindir}/zabbix_proxy
%{_mandir}/man1/zabbix_proxy.1%{?ext_man}
%{_mandir}/man1/zabbix_proxy_mysql.1%{?ext_man}
%doc database/mysql/schema.sql.gz
%endif

%if 0%{?_with_postgresql:1}

%package proxy-postgresql
Summary:        	Zabbix proxy with PostgreSQL support
Group:          	System/Monitoring
Provides:       	zabbix_proxy_binary = %{version}-%{release}
Requires:       	%{name}-proxy = %{version}-%{release}
Requires(post): 	update-alternatives
Requires(postun): 	update-alternatives
Requires:		fping
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Provides:		zabbix-proxy = %{version}-%{release}
Provides:		zabbix-proxy-implementation = %{version}-%{release}
Obsoletes:		zabbix < %{version}
Conflicts:		zabbix-proxy-mysql
Conflicts:		zabbix-proxy-sqlite3

%description proxy-postgresql
The Zabbix proxy compiled with PostgreSQL support.

%preun proxy-postgresql
if [ "$1" = 0 ] ; then
        %{_sbindir}/update-alternatives --remove zabbix_proxy %{_sbindir}/zabbix_proxy_postgresql
fi

%post proxy-postgresql
%{_sbindir}/update-alternatives --install %{_sbindir}/zabbix_proxy zabbix_proxy %{_sbindir}/zabbix_proxy_postgresql 11 \
	--slave %{_mandir}/man1/zabbix_proxy.1%{?ext_man} zabbix_proxy.1%{?ext_man} %{_mandir}/man1/zabbix_proxy_postgresql.1%{?ext_man}

%files proxy-postgresql
%defattr(-,root,root)
%{_sbindir}/zabbix_proxy_postgresql
%if 0%{?suse_version} >= 1130
%ghost %_sysconfdir/alternatives/zabbix_proxy
%ghost %_sysconfdir/alternatives/zabbix_proxy.1%{?ext_man}
%endif
%{_sbindir}/zabbix_proxy
%{_mandir}/man1/zabbix_proxy.1%{?ext_man}
%{_mandir}/man1/zabbix_proxy_postgresql.1%{?ext_man}
%endif
%doc database/postgresql/schema.sql.gz

%if 0%{?_with_sqlite3:1}

%package proxy-sqlite3
Summary:        Zabbix proxy with SQLite support
Group:          System/Monitoring
Provides:       %{name} = %{version}-%{release}
Provides:       zabbix_proxy_binary = %{version}-%{release}
Requires:       %{name}-proxy = %{version}-%{release}
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires:			fping
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Provides:			zabbix-proxy = %{version}-%{release}
Provides:			zabbix-proxy-implementation = %{version}-%{release}
Obsoletes:			zabbix < %{version}
Conflicts:			zabbix-proxy-postgresql
Conflicts:			zabbix-proxy-mysql

%description proxy-sqlite3
The Zabbix proxy compiled with SQLite support.

%preun proxy-sqlite3
if [ "$1" = 0 ] ; then
        %{_sbindir}/update-alternatives --remove zabbix_proxy %{_sbindir}/zabbix_proxy_sqlite
fi

%post proxy-sqlite3
%{_sbindir}/update-alternatives --install %{_sbindir}/zabbix_proxy zabbix_proxy %{_sbindir}/zabbix_proxy_sqlite3 10 \
	--slave %{_mandir}/man1/zabbix_proxy.1%{?ext_man} zabbix_proxy.1%{?ext_man} %{_mandir}/man1/zabbix_proxy_sqlite3.1%{?ext_man}

%files proxy-sqlite3
%defattr(-,root,root)
%{_sbindir}/zabbix_proxy_sqlite3
 %if 0%{?suse_version} >= 1130
%ghost %_sysconfdir/alternatives/zabbix_proxy
%ghost %_sysconfdir/alternatives/zabbix_proxy.1%{?ext_man}
 %endif
%{_sbindir}/zabbix_proxy
%{_mandir}/man1/zabbix_proxy.1%{?ext_man}
%{_mandir}/man1/zabbix_proxy_sqlite3.1%{?ext_man}
%doc database/sqlite3/schema.sql.gz

%endif
%endif #_enable_proxy


%if 0%{?with_java:1}

%package java-gateway
Summary:		Zabbix java gateway
Group:			System/Monitoring
%if 0%{?rhel} >= 7
Requires:		java-headless >= 1.6.0
%else
Requires:		java >= 1.6.0
%endif
%if 0%{?_unitdir:1}
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd
%else
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Requires(preun):	/sbin/service
Requires(postun):	/sbin/service
%endif
Obsoletes:		zabbix < %{version}

%description java-gateway
Zabbix to java jmx gateway

%pre java-gateway
 %if 0%{?suse_version} >= 1210
%service_add_pre zabbix-java-gateway.service
 %endif
%{_bindir}/getent group %{zabbix_group} >/dev/null || %{_sbindir}/groupadd -r %{zabbix_group} || :
%{_bindir}/getent passwd %{zabbix_user} >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/%{zabbix_user} -s /bin/false -c "Zabbix Java Daemon" -g %{zabbix_group} %{zabbix_user} || :

%post java-gateway
 %if 0%{?suse_version} >= 1210
%service_add_post zabbix-java-gateway.service
%tmpfiles_create %_tmpfilesdir/zabbix-java-gateway.conf
 %else
%fillup_and_insserv -f zabbix-java-gateway
 %endif

%preun java-gateway
 %if 0%{?suse_version} >= 1220
%service_del_preun zabbix-java-gateway.service
 %else
%stop_on_removal zabbix-java-gateway
 %endif

%postun java-gateway
 %if 0%{?suse_version} >= 1220
%service_del_postun zabbix-java-gateway.service
 %else
%restart_on_update zabbix-java-gateway
%insserv_cleanup
 %endif
 
%files java-gateway
%defattr(-,root,root)
%dir %{_sysconfdir}/zabbix
%config(noreplace) %attr(0640, root, %{zabbix_group}) %{_sysconfdir}/zabbix/zabbix_java_gateway.conf
%config(noreplace) %attr(0640, root, %{zabbix_group}) %{_sysconfdir}/zabbix/zabbix_java_gateway_log.xml
%dir %{_prefix}/lib/zabbix-java-gateway
%{_bindir}/zabbix-java-gateway
%{_prefix}/lib/zabbix-java-gateway/zabbix-java-gateway-%{version}%{?rclevel}.jar
%{_prefix}/lib/zabbix-java-gateway/android-json-4.3_r3.1.jar
%{_prefix}/lib/zabbix-java-gateway/slf4j-api-1.6.1.jar
%{_prefix}/lib/zabbix-java-gateway/logback-core-0.9.27.jar
%{_prefix}/lib/zabbix-java-gateway/logback-classic-0.9.27.jar
%{_sbindir}/rczabbix-java-gateway
%attr(0750,root,%{zabbix_group}) %dir %{_localstatedir}/log/%{zabbix_user}
%ghost %attr(0750,root,%{zabbix_group}) %dir %{_rundir}/%{zabbix_user}
%if 0%{?_unitdir:1}
%{_unitdir}/zabbix-java-gateway.service
%{_prefix}/lib/tmpfiles.d/zabbix-java-gateway.conf
%else
%{_initddir}/zabbix-java-gateway
%endif
%if 0%{?suse_version} > 1020
%config %{SuSeFirewall_services_dir}/zabbix-java-gateway
%endif
%{_sbindir}/zabbix_java_gateway
%endif #_with_java