SPECS/zookeeper/zookeeper.spec
c14f8caa
 Summary:        Highly reliable distributed coordination
 Name:           zookeeper
454854a9
 Version:        3.4.10
8c91b2bd
 Release:        4%{?dist}
c14f8caa
 URL:            http://zookeeper.apache.org/
 License:        Apache License, Version 2.0
 Group:          Applications/System
 Vendor:         VMware, Inc.
 Distribution:   Photon
 Source:         http://mirrors.ocf.berkeley.edu/apache/zookeeper/zookeeper-3.4.9/%{name}-%{version}.tar.gz
454854a9
 %define sha1 zookeeper=eb2145498c5f7a0d23650d3e0102318363206fba
c14f8caa
 Source1:        zookeeper.service
 Source2:        zkEnv.sh
 Patch0:	        zookeeper-3.4.8-server.patch
ebcd0400
 BuildRequires:  systemd
 Requires:       systemd
c14f8caa
 Requires:       shadow
8c91b2bd
 Requires:       openjre8
f8685061
 %description
 ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them ,which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.
 
 %prep
 %setup -q
bf8c5d2e
 %patch0 -p1
f8685061
 
 %install
 mkdir -p %{buildroot}%{_prefix}
 mkdir -p %{buildroot}%{_bindir}
bf8c5d2e
 mkdir -p %{buildroot}%{_libdir}/java/zookeeper
 mkdir -p %{buildroot}%{_libdir}/zookeeper
f8685061
 mkdir -p %{buildroot}%{_var}/log/zookeeper
 mkdir -p %{buildroot}%{_sysconfdir}/zookeeper
 mkdir -p %{buildroot}/sbin
 mkdir -p %{buildroot}%{_prefix}/share/zookeeper/templates/conf
 mkdir -p %{buildroot}%{_var}/zookeeper
 
bf8c5d2e
 cp zookeeper-%{version}.jar %{buildroot}%{_libdir}/java/zookeeper
f8685061
 cp src/packages/update-zookeeper-env.sh %{buildroot}/sbin/update-zookeeper-env.sh
 cp src/packages/templates/conf/zookeeper-env.sh %{buildroot}%{_prefix}/share/zookeeper/templates/conf
 cp conf/zoo_sample.cfg %{buildroot}%{_prefix}/share/zookeeper/templates/conf/zoo.cfg
 chmod 0755 %{buildroot}/sbin/*
 
 mv bin/* %{buildroot}%{_bindir}
bf8c5d2e
 mv lib/*.jar %{buildroot}%{_libdir}/java/zookeeper
 mv lib/* %{buildroot}%{_libdir}/zookeeper
f8685061
 mv conf/zoo_sample.cfg %{buildroot}%{_sysconfdir}/zookeeper/zoo.cfg
 mv conf/* %{buildroot}%{_sysconfdir}/zookeeper
c1cdac1f
 pushd ..
f8685061
 rm -rf %{buildroot}/%{name}-%{version}
c1cdac1f
 popd
 
 mkdir -p %{buildroot}/lib/systemd/system
bf8c5d2e
 cp %{SOURCE1} %{buildroot}/lib/systemd/system/zookeeper.service
 cp %{SOURCE2} %{buildroot}%{_bindir}/zkEnv.sh
a2497ffa
 
 install -vdm755 %{buildroot}/lib/systemd/system-preset
 echo "disable zookeeper.service" > %{buildroot}/lib/systemd/system-preset/50-zookeeper.preset
 
f8685061
 %pre
4ed708e1
 getent group hadoop >/dev/null || /usr/sbin/groupadd -r hadoop
 getent passwd zookeeper >/dev/null || /usr/sbin/useradd --comment "ZooKeeper" --shell /bin/bash -M -r --groups hadoop --home %{_prefix}/share/zookeeper zookeeper
f8685061
 
 %post
f66608a4
 if [ $1 -eq 1 ] ; then
     # Initial installation
     # Enabled by default per "runs once then goes away" exception
     source %{_sysconfdir}/profile.d/java-exports.sh
     bash %{_prefix}/sbin/update-zookeeper-env.sh \
f8685061
        --prefix=%{_prefix} \
        --conf-dir=%{_sysconfdir}/zookeeper \
        --log-dir=%{_var}/log/zookeeper \
bf8c5d2e
        --pid-dir=%{_var}/run/zookeeper \
f8685061
        --var-dir=%{_var}/zookeeper
c1cdac1f
 fi
f66608a4
 %{_sbindir}/ldconfig
 %systemd_post zookeeper.service
  
f8685061
 %preun
f66608a4
 if [ $1 -eq 0 ] ; then
345c7c44
 source %{_sysconfdir}/profile.d/java-exports.sh
f8685061
 bash %{_prefix}/sbin/update-zookeeper-env.sh \
        --prefix=%{_prefix} \
        --conf-dir=%{_sysconfdir}/zookeeper \
        --log-dir=%{_var}/log/zookeeper \
bf8c5d2e
        --pid-dir=%{_var}/run/zookeeper \
f8685061
        --var-dir=%{_var}/zookeeper \
        --uninstall
f66608a4
 fi
 %systemd_preun zookeeper.service
f8685061
 
345c7c44
 %postun
ba416d95
 %systemd_postun_with_restart zookeeper.service
f66608a4
 if [ $1 -eq 0 ] ; then
     /usr/sbin/userdel zookeeper
     /usr/sbin/groupdel hadoop
 fi
345c7c44
 /sbin/ldconfig
97c9dddf
 
f8685061
 %files
 %defattr(-,root,root)
bf8c5d2e
 %attr(0755,zookeeper,hadoop) %{_var}/log/zookeeper
 %attr(0775,zookeeper,hadoop) /sbin/update-zookeeper-env.sh
f8685061
 %config(noreplace) %{_sysconfdir}/zookeeper/*
c1cdac1f
 /lib/systemd/system/zookeeper.service
a2497ffa
 /lib/systemd/system-preset/50-zookeeper.preset
f8685061
 %{_prefix}
 
 %changelog
8c91b2bd
 *   Thu Jun 01 2017 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 3.4.10-4
 -   Renamed openjdk to openjdk8.
a2497ffa
 *   Wed May 31 2017 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 3.4.10-3
 -   Provide preset to disable service by default
2d790fde
 *   Wed May 24 2017 Xiaolin Li <xiaolinl@vmware.com> 3.4.10-2
 -   Used RuntimeDirectory to create folder /var/run/zookeeper.
454854a9
 *   Wed Apr 05 2017 Xiaolin Li <xiaolinl@vmware.com> 3.4.10-1
 -   Updated to version 3.4.10.
c14f8caa
 *   Mon Nov 28 2016 Vinay Kulkarni <kulkarniv@vmware.com> 3.4.9-1
 -   Upgrade to 3.4.9 to address CVE-2016-5017
 *   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 3.4.8-4
 -   GA - Bump release of all rpms
f66608a4
 *   Mon May 2 2016 Divya Thaluru <dthaluru@vmware.com>  3.4.8-3
 -   Fixing spec file to handle rpm upgrade scenario correctly
bf8c5d2e
 *   Thu Apr 28 2016 Divya Thaluru <dthaluru@vmware.com>  3.4.8-2
 -   Added logic to set classpath
0bc3a918
 *   Wed Feb 24 2016 Kumar Kaushik <kaushikk@vmware.com>  3.4.8-1
 -   Updating version.
4ed708e1
 *   Fri Feb 05 2016 Anish Swaminathan <anishs@vmware.com>  3.4.6-8
 -   Edit pre install script.
2e967102
 *   Tue Jan 12 2016 Anish Swaminathan <anishs@vmware.com>  3.4.6-7
 -   Remove init.d file.
ebcd0400
 *   Thu Dec 10 2015 Xiaolin Li <xiaolinl@vmware.com>  3.4.6-6
 -   Add systemd to Requires and BuildRequires.
4ed708e1
 *   Wed Nov 18 2015 Xiaolin Li <xiaolinl@vmware.com> 3.4.6-5
 -   Add zookeeper to systemd service.
 *   Tue Nov 10 2015 Mahmoud Bassiouny<mbassiouny@vmware.com> 3.4.6-4
 -   Fix conflicts between zookeeper and chkconfig
 *   Wed Sep 16 2015 Harish Udaiya Kumar<hudaiyakumar@vmware.com> 3.4.6-3
 -   Udating the dependency after repackaging the openjdk, fixed post scripts
 *   Wed Aug 05 2015 Kumar Kaushik <kaushikk@vmware.com> 3.4.6-2
 -   Adding ldconfig in post section.
 *   Thu Jun 11 2015 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 3.4.6-1
 -   Initial build. First version	Initial build. First version