full of … these

hazelcast rpm spec file and init script

Posted: November 9th, 2013 | Author: | Filed under: Uncategorized | No Comments »

Here is how I have built the rpm for hazelcast.

Download and unpack:

wget http://www.hazelcast.com/files/hazelcast-3.1.1.zip

unzip hazelcast-3.1.1.zip

Create a dir for building the rpm:

mkdir -p rpm-build/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

Copy sources and init file to SOURCES dir:

cp -r hazelcast-3.1.1 hazelcats-init rpm-root/SOURCES/

 

hazelcast.spec:

Name:           hazelcast
Version:        3.1.1
Release:        1
Summary:        hazelcast
Group:          hazelcast
License:        GPL
URL:            http://www.hazelcast.com
#Source0:
BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch:      noarch
#BuildRequires:
#Requires:
%description
hazelcast 3.1.1
%prep
%build
%install
mkdir -p $RPM_BUILD_ROOT/opt/hazelcast/lib
mkdir -p $RPM_BUILD_ROOT/opt/hazelcast/bin
mkdir -p $RPM_BUILD_ROOT/etc/init.d
cp -Rip %{_sourcedir}/hazelcast-3.1.1/{bin,lib} $RPM_BUILD_ROOT/opt/hazelcast/
cp      %{_sourcedir}/hazelcast-init $RPM_BUILD_ROOT/etc/init.d/hazelcast
%clean
rm -rf $RPM_BUILD_ROOT
%files
%dir /opt/hazelcast
/opt/hazelcast/lib
/opt/hazelcast/bin
%attr(0755,root,root) /etc/init.d/hazelcast
%changelog
* Fri Nov 08 2013 - pjurco@localhost

- First version

hazelcast-init:

#!/bin/sh
### BEGIN INIT INFO
# Provides: hazelcast
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop hazelcast
# Description: Start, stop and hazelcast
### END INIT INFO
HAZELCAST_HOME=/opt/hazelcast
PID_FILE=/var/run/hazelcast.pid
if [ "$1" = "start" ]; then
#execute some command in the background here, using
cd $HAZELCAST_HOME/bin && ./server.sh &
#the "&"-sign at the end of the command
PID=`ps -ef | grep -v grep | grep -m 1 "StartServer" | awk '{print $2}'`
echo "$PID" > $PID_FILE
elif [ "$1" = "stop" ]; then
kill -9 `cat $PID_FILE`
rm $PID_FILE
else
echo "Usage: hazelcast start|stop"
exit 1

Build command is:

rpmbuild --define '_topdir '`pwd`/rpm-root -ba hazelcast.spec


Leave a Reply