Return-Path: X-Original-To: apmail-zookeeper-commits-archive@www.apache.org Delivered-To: apmail-zookeeper-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CE6D8790F for ; Mon, 29 Aug 2011 21:27:12 +0000 (UTC) Received: (qmail 52755 invoked by uid 500); 29 Aug 2011 21:27:12 -0000 Delivered-To: apmail-zookeeper-commits-archive@zookeeper.apache.org Received: (qmail 52719 invoked by uid 500); 29 Aug 2011 21:27:12 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 52711 invoked by uid 99); 29 Aug 2011 21:27:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Aug 2011 21:27:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Aug 2011 21:27:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0863B23889E7 for ; Mon, 29 Aug 2011 21:26:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1163014 - in /zookeeper/trunk: ./ bin/ src/contrib/ src/contrib/zkpython/ src/contrib/zkpython/src/packages/ src/contrib/zkpython/src/packages/deb/ src/contrib/zkpython/src/packages/deb/zkpython.control/ src/contrib/zkpython/src/packages/r... Date: Mon, 29 Aug 2011 21:26:45 -0000 To: commits@zookeeper.apache.org From: phunt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110829212647.0863B23889E7@eris.apache.org> Author: phunt Date: Mon Aug 29 21:26:44 2011 New Revision: 1163014 URL: http://svn.apache.org/viewvc?rev=1163014&view=rev Log: ZOOKEEPER-999. Create an package integration project Added: zookeeper/trunk/README_packaging.txt zookeeper/trunk/src/contrib/zkpython/ivy.xml zookeeper/trunk/src/contrib/zkpython/src/packages/ zookeeper/trunk/src/contrib/zkpython/src/packages/deb/ zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/ zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/ zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/ zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec zookeeper/trunk/src/packages/ zookeeper/trunk/src/packages/deb/ zookeeper/trunk/src/packages/deb/init.d/ zookeeper/trunk/src/packages/deb/init.d/zookeeper zookeeper/trunk/src/packages/deb/zookeeper.control/ zookeeper/trunk/src/packages/deb/zookeeper.control/conffile zookeeper/trunk/src/packages/deb/zookeeper.control/control zookeeper/trunk/src/packages/deb/zookeeper.control/postinst zookeeper/trunk/src/packages/deb/zookeeper.control/postrm zookeeper/trunk/src/packages/deb/zookeeper.control/preinst zookeeper/trunk/src/packages/deb/zookeeper.control/prerm zookeeper/trunk/src/packages/rpm/ zookeeper/trunk/src/packages/rpm/init.d/ zookeeper/trunk/src/packages/rpm/init.d/zookeeper zookeeper/trunk/src/packages/rpm/spec/ zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec zookeeper/trunk/src/packages/templates/ zookeeper/trunk/src/packages/templates/conf/ zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh zookeeper/trunk/src/packages/update-zookeeper-env.sh Modified: zookeeper/trunk/bin/zkCleanup.sh zookeeper/trunk/bin/zkCli.sh zookeeper/trunk/bin/zkEnv.sh zookeeper/trunk/bin/zkServer.sh zookeeper/trunk/build.xml zookeeper/trunk/ivy.xml zookeeper/trunk/src/contrib/build-contrib.xml zookeeper/trunk/src/contrib/build.xml zookeeper/trunk/src/contrib/zkpython/build.xml zookeeper/trunk/src/contrib/zkpython/src/python/setup.py zookeeper/trunk/src/recipes/build-recipes.xml zookeeper/trunk/src/recipes/build.xml zookeeper/trunk/src/recipes/lock/build.xml zookeeper/trunk/src/recipes/queue/build.xml Added: zookeeper/trunk/README_packaging.txt URL: http://svn.apache.org/viewvc/zookeeper/trunk/README_packaging.txt?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/README_packaging.txt (added) +++ zookeeper/trunk/README_packaging.txt Mon Aug 29 21:26:44 2011 @@ -0,0 +1,65 @@ +README file for Packaging Notes + +Requirement +----------- + +gcc, cppunit and python-setuptools are required to build +C and python bindings. + +On RHEL machine: + +yum install cppunit +yum install python-setuptools + +On Ubuntu: + +apt-get --install cppunit +apt-get --install python-setuptools + +Package build command +--------------------- + +Command to build Debian package: ant deb +Command to build RPM Package: ant rpm + +rpm and deb packages are generated and placed in: + +build/zookeeper*.[rpm|deb] +build/contrib/**.[rpm|deb] + +Default package file structure layout + + /usr/bin - User executable + /usr/sbin - System executable + /usr/libexec - Configuration boot trap script + /usr/lib - Native libraries + /usr/share/doc/zookeeper - Documents + /usr/share/zookeeper - Project files + /usr/share/zookeeper/template/conf - Configuration template files + /etc/zookeeper - Configuration files + /etc/init.d/zookeeper - OS startup script + +Source file structure layout +--------------------- + +src/packages/update-zookeeper-env.sh + - setup environment variables and symlink $PREFIX/etc/zookeeper to + /etc/zookeeper. + - This script is designed to run in post installation, and pre-remove + phase of ZooKeeper package. + - Run update-zookeeper-env.sh -h to get a list of supported parameters. + +src/packages/template + - Standard configuration template + +src/packages/deb + Meta data for creating Debian package + +src/packages/deb/init.d + Daemon start/stop script for Debian flavor of Linux + +src/packages/rpm + Meta data for creating RPM package + +src/packages/rpm/init.d + Daemon start/stop script for Redhat flavor of Linux Modified: zookeeper/trunk/bin/zkCleanup.sh URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkCleanup.sh?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/bin/zkCleanup.sh (original) +++ zookeeper/trunk/bin/zkCleanup.sh Mon Aug 29 21:26:44 2011 @@ -25,16 +25,16 @@ # relative to the canonical path of this script. # -# Only follow symlinks if readlink supports it -if readlink -f "$0" > /dev/null 2>&1 -then - ZOOBIN=`readlink -f "$0"` +# use POSTIX interface, symlink is followed automatically +ZOOBIN="${BASH_SOURCE-$0}" +ZOOBIN=`dirname ${ZOOBIN}` +ZOOBINDIR=`cd ${ZOOBIN}; pwd` + +if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then + . "$ZOOBINDIR"/../libexec/zkEnv.sh else - ZOOBIN="$0" + . "$ZOOBINDIR"/zkEnv.sh fi -ZOOBINDIR=`dirname "$ZOOBIN"` - -. "$ZOOBINDIR"/zkEnv.sh ZOODATADIR=$(grep "^[[:space:]]*dataDir=" "$ZOOCFG" | sed -e 's/.*=//') ZOODATALOGDIR=$(grep "^[[:space:]]*dataLogDir=" "$ZOOCFG" | sed -e 's/.*=//') Modified: zookeeper/trunk/bin/zkCli.sh URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkCli.sh?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/bin/zkCli.sh (original) +++ zookeeper/trunk/bin/zkCli.sh Mon Aug 29 21:26:44 2011 @@ -25,16 +25,16 @@ # relative to the canonical path of this script. # -# Only follow symlinks if readlink supports it -if readlink -f "$0" > /dev/null 2>&1 -then - ZOOBIN=`readlink -f "$0"` +# use POSTIX interface, symlink is followed automatically +ZOOBIN="${BASH_SOURCE-$0}" +ZOOBIN=`dirname ${ZOOBIN}` +ZOOBINDIR=`cd ${ZOOBIN}; pwd` + +if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then + . "$ZOOBINDIR"/../libexec/zkEnv.sh else - ZOOBIN="$0" + . "$ZOOBINDIR"/zkEnv.sh fi -ZOOBINDIR=`dirname "$ZOOBIN"` - -. "$ZOOBINDIR"/zkEnv.sh $JAVA "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \ -cp "$CLASSPATH" $CLIENT_JVMFLAGS $JVMFLAGS \ Modified: zookeeper/trunk/bin/zkEnv.sh URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkEnv.sh?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/bin/zkEnv.sh (original) +++ zookeeper/trunk/bin/zkEnv.sh Mon Aug 29 21:26:44 2011 @@ -22,9 +22,21 @@ # otherwise we use /etc/zookeeper # or the conf directory that is # a sibling of this script's directory + +ZOOBINDIR=${ZOOBINDIR:-/usr/bin} +ZOOKEEPER_PREFIX=${ZOOBINDIR}/.. + if [ "x$ZOOCFGDIR" = "x" ] then + if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then ZOOCFGDIR="$ZOOBINDIR/../conf" + else + ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper" + fi +fi + +if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then + . "${ZOOCFGDIR}/zookeeper-env.sh" fi if [ "x$ZOOCFG" = "x" ] @@ -64,13 +76,13 @@ do done #make it work in the release -for i in "$ZOOBINDIR"/../lib/*.jar -do - CLASSPATH="$i:$CLASSPATH" -done +if [ -d ${ZOOKEEPER_PREFIX}/share/zookeeper ]; then + LIBPATH="${ZOOKEEPER_PREFIX}"/share/zookeeper/*.jar +else + LIBPATH="${ZOOBINDIR}"/../lib/*.jar +fi -#make it work in the release -for i in "$ZOOBINDIR"/../zookeeper-*.jar +for i in ${LIBPATH} do CLASSPATH="$i:$CLASSPATH" done Modified: zookeeper/trunk/bin/zkServer.sh URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkServer.sh?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/bin/zkServer.sh (original) +++ zookeeper/trunk/bin/zkServer.sh Mon Aug 29 21:26:44 2011 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -42,16 +42,16 @@ else ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain" fi -# Only follow symlinks if readlink supports it -if readlink "$0" > /dev/null 2>&1 -then - ZOOBIN=`readlink "$0"` +# use POSTIX interface, symlink is followed automatically +ZOOBIN="${BASH_SOURCE-$0}" +ZOOBIN=`dirname ${ZOOBIN}` +ZOOBINDIR=`cd ${ZOOBIN}; pwd` + +if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then + . "$ZOOBINDIR"/../libexec/zkEnv.sh else - ZOOBIN="$0" + . "$ZOOBINDIR"/zkEnv.sh fi -ZOOBINDIR=`dirname "$ZOOBIN"` - -. "$ZOOBINDIR"/zkEnv.sh if [ "x$SERVER_JVMFLAGS" ] then Modified: zookeeper/trunk/build.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/build.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/build.xml (original) +++ zookeeper/trunk/build.xml Mon Aug 29 21:26:44 2011 @@ -103,6 +103,7 @@ value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" /> + @@ -150,6 +151,20 @@ + + + + + + + + + + + + + + @@ -194,6 +209,12 @@ + + + + + + @@ -201,6 +222,7 @@ + @@ -313,6 +335,11 @@ pattern="${ivy.test.lib}/[artifact]-[revision].[ext]"/> + + + + + + + + + + + + + + + + + + + + + + + + + @@ -585,20 +635,25 @@ description="Build distribution"> - - + + + + + - + + + @@ -608,12 +663,12 @@ - + - - + + @@ -655,7 +710,15 @@ - + + + + + + + + + @@ -679,9 +742,20 @@ + + + + + + + + /tmp/zookeeper + ${VAR_DIR}/data + + @@ -756,6 +830,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -774,6 +999,7 @@ + @@ -896,6 +1122,7 @@ + @@ -925,9 +1152,8 @@ depends="compile_jute, jar, create-cppunit-makefile" if="cppunit" description="to run cppunit test cases"> - - + Modified: zookeeper/trunk/ivy.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/ivy.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/ivy.xml (original) +++ zookeeper/trunk/ivy.xml Mon Aug 29 21:26:44 2011 @@ -26,14 +26,16 @@ + + - + @@ -48,6 +50,8 @@ + + Modified: zookeeper/trunk/src/contrib/build-contrib.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/build-contrib.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/contrib/build-contrib.xml (original) +++ zookeeper/trunk/src/contrib/build-contrib.xml Mon Aug 29 21:26:44 2011 @@ -153,6 +153,28 @@ + + + + + + + + + + + + + + + + + + + + + + Modified: zookeeper/trunk/src/contrib/build.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/build.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/contrib/build.xml (original) +++ zookeeper/trunk/src/contrib/build.xml Mon Aug 29 21:26:44 2011 @@ -48,7 +48,7 @@ - + @@ -68,4 +68,21 @@ + + + + + + + + + + + + + + + + + Modified: zookeeper/trunk/src/contrib/zkpython/build.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/build.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/contrib/zkpython/build.xml (original) +++ zookeeper/trunk/src/contrib/zkpython/build.xml Mon Aug 29 21:26:44 2011 @@ -25,6 +25,10 @@ + + + + @@ -57,7 +61,7 @@ - + @@ -94,5 +98,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: zookeeper/trunk/src/contrib/zkpython/ivy.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/ivy.xml?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/contrib/zkpython/ivy.xml (added) +++ zookeeper/trunk/src/contrib/zkpython/ivy.xml Mon Aug 29 21:26:44 2011 @@ -0,0 +1,43 @@ + + + + + + + + ZKPython + + + + + + + + + + + + + + + + + + Added: zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control (added) +++ zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control Mon Aug 29 21:26:44 2011 @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +Package: zkpython +Version: @version@ +Section: misc +Priority: optional +Architecture: all +Depends: python +Maintainer: Apache Software Foundation +Description: ZooKeeper python binding library +Distribution: development Added: zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec (added) +++ zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec Mon Aug 29 21:26:44 2011 @@ -0,0 +1,82 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# RPM Spec file for ZooKeeper version @version@ +# + +%define name zkpython +%define version @version@ +%define release @package.release@ + +# Installation Locations +%define _prefix @package.prefix@ + +# Build time settings +%define _build_dir @package.build.dir@ +%define _final_name @final.name@ +%define _python_lib @python.lib@ +%define debug_package %{nil} + +# Disable brp-java-repack-jars for aspect J +%define __os_install_post \ + /usr/lib/rpm/redhat/brp-compress \ + %{!?__debug_package:/usr/lib/rpm/redhat/brp-strip %{__strip}} \ + /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \ + /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \ + /usr/lib/rpm/brp-python-bytecompile %{nil} + +# RPM searches perl files for dependancies and this breaks for non packaged perl lib +# like thrift so disable this +%define _use_internal_dependency_generator 0 + +Summary: ZooKeeper python binding library +Group: Development/Libraries +License: Apache License, Version 2.0 +URL: http://zookeeper.apache.org/ +Vendor: Apache Software Foundation +Name: %{name} +Version: %{version} +Release: %{release} +Source0: %{_python_lib} +Prefix: %{_prefix} +Buildroot: %{_build_dir} +Requires: zookeeper-lib == %{version} +AutoReqProv: no +Provides: zkpython + +%description +ZooKeeper python binding library + +%prep +tar fxz %{_python_lib} -C %{_build_dir} + +%build + +######################### +#### INSTALL SECTION #### +######################### +%install + +%pre + +%post + +%preun + +%files +%defattr(-,root,root) +%{_prefix} + Modified: zookeeper/trunk/src/contrib/zkpython/src/python/setup.py URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/src/python/setup.py?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/contrib/zkpython/src/python/setup.py (original) +++ zookeeper/trunk/src/contrib/zkpython/src/python/setup.py Mon Aug 29 21:26:44 2011 @@ -21,9 +21,11 @@ zookeeper_basedir = "../../../" zookeepermodule = Extension("zookeeper", sources=["src/c/zookeeper.c"], include_dirs=[zookeeper_basedir + "/src/c/include", + zookeeper_basedir + "/build/c", zookeeper_basedir + "/src/c/generated"], libraries=["zookeeper_mt"], library_dirs=[zookeeper_basedir + "/src/c/.libs/", + zookeeper_basedir + "/build/c/.libs/", zookeeper_basedir + "/build/test/test-cppunit/.libs", "/usr/local/lib" ]) Added: zookeeper/trunk/src/packages/deb/init.d/zookeeper URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/init.d/zookeeper?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/init.d/zookeeper (added) +++ zookeeper/trunk/src/packages/deb/init.d/zookeeper Mon Aug 29 21:26:44 2011 @@ -0,0 +1,129 @@ +#! /bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +### BEGIN INIT INFO +# Provides: zookeeper +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Apache ZooKeeper server +### END INIT INFO + +set -e + +# /etc/init.d/zookeeper: start and stop the Apache ZooKeeper daemon + +umask 022 + +. /usr/libexec/zkEnv.sh + +. /lib/lsb/init-functions + +ZOOPIDFILE=/var/lib/zookeeper/data/zookeeper_server.pid + +# Are we running from init? +run_by_init() { + ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ] +} + +check_for_no_start() { + # forget it if we're trying to start, and /etc/zookeeper/zookeeper_not_to_be_run exists + if [ -e /etc/zookeeper/zookeeper_not_to_be_run ]; then + if [ "$1" = log_end_msg ]; then + log_end_msg 0 + fi + if ! run_by_init; then + log_action_msg "Apache ZooKeeper server not in use (/etc/zookeeper/zookeeper_not_to_be_run)" + fi + exit 0 + fi +} + +export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin" + +case "$1" in + start) + check_for_no_start + log_daemon_msg "Starting Apache ZooKeeper server" "zookeeper" + if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c zookeeper -x ${ZOOKEEPER_PREFIX}/sbin/zkServer.sh start; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping Apache ZooKeeper server" "zookeeper" + if start-stop-daemon --stop --quiet --oknodo --pidfile ${ZOOPIDFILE}; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + + restart) + check_privsep_dir + log_daemon_msg "Restarting Apache ZooKeeper server" "zookeeper" + start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${ZOOPIDFILE} + check_for_no_start log_end_msg + if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c zookeeper -x ${ZOOKEEPER_PREFIX}/bin/zkServer.sh start; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + + try-restart) + check_privsep_dir + log_daemon_msg "Restarting Apache ZooKeeper server" "zookeeper" + set +e + start-stop-daemon --stop --quiet --retry 30 --pidfile ${ZOOPIDFILE} + RET="$?" + set -e + case $RET in + 0) + # old daemon stopped + check_for_no_start log_end_msg + if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c zookeeper -x ${ZOOKEEPER_PREFIX}/bin/zkServer.sh start; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + 1) + # daemon not running + log_progress_msg "(not running)" + log_end_msg 0 + ;; + *) + # failed to stop + log_progress_msg "(failed to stop)" + log_end_msg 1 + ;; + esac + ;; + + status) + status_of_proc -p ${ZOOPIDFILE} ${JAVA_HOME}/bin/java zookeeper && exit 0 || exit $? + ;; + + *) + log_action_msg "Usage: /etc/init.d/zookeeper {start|stop|restart|try-restart|status}" + exit 1 +esac + +exit 0 Added: zookeeper/trunk/src/packages/deb/zookeeper.control/conffile URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/conffile?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/zookeeper.control/conffile (added) +++ zookeeper/trunk/src/packages/deb/zookeeper.control/conffile Mon Aug 29 21:26:44 2011 @@ -0,0 +1,15 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +/etc/zookeeper Added: zookeeper/trunk/src/packages/deb/zookeeper.control/control URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/control?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/zookeeper.control/control (added) +++ zookeeper/trunk/src/packages/deb/zookeeper.control/control Mon Aug 29 21:26:44 2011 @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +Package: zookeeper +Version: @version@ +Section: misc +Priority: optional +Architecture: all +Depends: sun-java6-jre +Maintainer: Apache Software Foundation +Description: ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. +Distribution: development Added: zookeeper/trunk/src/packages/deb/zookeeper.control/postinst URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/postinst?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/zookeeper.control/postinst (added) +++ zookeeper/trunk/src/packages/deb/zookeeper.control/postinst Mon Aug 29 21:26:44 2011 @@ -0,0 +1,23 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bash /usr/sbin/update-zookeeper-env.sh \ + --prefix=/usr \ + --conf-dir=/etc/zookeeper \ + --log-dir=/var/log/zookeeper \ + --pid-dir=/var/run/zookeeper \ + --var-dir=/var/lib/zookeeper Added: zookeeper/trunk/src/packages/deb/zookeeper.control/postrm URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/postrm?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/zookeeper.control/postrm (added) +++ zookeeper/trunk/src/packages/deb/zookeeper.control/postrm Mon Aug 29 21:26:44 2011 @@ -0,0 +1,19 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +/usr/sbin/userdel zookeeper 2> /dev/null >/dev/null +exit 0 Added: zookeeper/trunk/src/packages/deb/zookeeper.control/preinst URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/preinst?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/zookeeper.control/preinst (added) +++ zookeeper/trunk/src/packages/deb/zookeeper.control/preinst Mon Aug 29 21:26:44 2011 @@ -0,0 +1,20 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +getent group hadoop 2>/dev/null >/dev/null || /usr/sbin/groupadd -r hadoop + +/usr/sbin/useradd --comment "ZooKeeper" --shell /bin/bash -M -r --groups hadoop --home /usr/share/zookeeper zookeeper 2> /dev/null || : Added: zookeeper/trunk/src/packages/deb/zookeeper.control/prerm URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/prerm?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/deb/zookeeper.control/prerm (added) +++ zookeeper/trunk/src/packages/deb/zookeeper.control/prerm Mon Aug 29 21:26:44 2011 @@ -0,0 +1,24 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +/etc/init.d/zookeeper stop 2>/dev/null >/dev/null +bash /usr/sbin/update-zookeeper-env.sh \ + --prefix=/usr \ + --conf-dir=/etc/zookeeper \ + --log-dir=/var/log/zookeeper \ + --pid-dir=/var/run/zookeeper \ + --uninstal Added: zookeeper/trunk/src/packages/rpm/init.d/zookeeper URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/rpm/init.d/zookeeper?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/rpm/init.d/zookeeper (added) +++ zookeeper/trunk/src/packages/rpm/init.d/zookeeper Mon Aug 29 21:26:44 2011 @@ -0,0 +1,84 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ZooKeeper +# +# chkconfig: 2345 89 9 +# description: zookeeper + +source /etc/rc.d/init.d/functions +source /usr/libexec/zkEnv.sh + +RETVAL=0 +PIDFILE="${ZOOPIDFILE}" +desc="ZooKeeper daemon" + +start() { + echo -n $"Starting $desc (zookeeper): " + daemon --user zookeeper zkServer.sh start + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zookeeper + return $RETVAL +} + +stop() { + echo -n $"Stopping $desc (zookeeper): " + daemon --user zookeeper zkServer.sh stop + RETVAL=$? + sleep 5 + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zookeeper $PIDFILE +} + +restart() { + stop + start +} + +checkstatus(){ + status -p $PIDFILE ${JAVA_HOME}/bin/java + RETVAL=$? +} + +condrestart(){ + [ -e /var/lock/subsys/zookeeper ] && restart || : +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + checkstatus + ;; + restart) + restart + ;; + condrestart) + condrestart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart}" + exit 1 +esac + +exit $RETVAL Added: zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec (added) +++ zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec Mon Aug 29 21:26:44 2011 @@ -0,0 +1,167 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# RPM Spec file for ZooKeeper version @version@ +# + +%define name zookeeper +%define version @version@ +%define release @package.release@ + +# Installation Locations +%define _prefix @package.prefix@ +%define _bin_dir %{_prefix}/bin +%define _conf_dir @package.conf.dir@ +%define _include_dir %{_prefix}/include +%define _lib_dir %{_prefix}/lib +%define _lib64_dir %{_prefix}/lib64 +%define _libexec_dir %{_prefix}/libexec +%define _log_dir @package.log.dir@ +%define _man_dir %{_prefix}/man +%define _pid_dir @package.pid.dir@ +%define _sbin_dir %{_prefix}/sbin +%define _share_dir %{_prefix}/share/zookeeper +%define _src_dir %{_prefix}/src +%define _var_dir @package.var.dir@ + +# Build time settings +%define _build_dir @package.build.dir@ +%define _final_name @final.name@ +%define _c_lib @c.lib@ +%define debug_package %{nil} + +# Disable brp-java-repack-jars for aspect J +%define __os_install_post \ + /usr/lib/rpm/redhat/brp-compress \ + %{!?__debug_package:/usr/lib/rpm/redhat/brp-strip %{__strip}} \ + /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \ + /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \ + /usr/lib/rpm/brp-python-bytecompile %{nil} + +# RPM searches perl files for dependancies and this breaks for non packaged perl lib +# like thrift so disable this +%define _use_internal_dependency_generator 0 + +Summary: ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. +License: Apache License, Version 2.0 +URL: http://zookeeper.apache.org/ +Vendor: Apache Software Foundation +Group: Development/Libraries +Name: %{name} +Version: %{version} +Release: %{release} +Source0: %{_final_name}.tar.gz +Source1: %{_final_name}-lib.tar.gz +Prefix: %{_prefix} +Prefix: %{_conf_dir} +Prefix: %{_log_dir} +Prefix: %{_pid_dir} +Prefix: %{_var_dir} +Buildroot: %{_build_dir} +Requires: sh-utils, textutils, /usr/sbin/useradd, /usr/sbin/usermod, /sbin/chkconfig, /sbin/service, jdk >= 1.6 +AutoReqProv: no +Provides: zookeeper + +%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. + +%package lib +Summary: ZooKeeper C binding library +Group: System/Libraries +#Requires: %{name} == %{version} +Provides: zookeeper-lib + +%description lib +ZooKeeper C client library for communicating with ZooKeeper Server. + +%prep +%setup -D -b 1 -n %{_final_name} +%setup -D -a 0 -n %{_final_name} + +%build +mkdir -p ${RPM_BUILD_DIR}%{_prefix} +mkdir -p ${RPM_BUILD_DIR}%{_bin_dir} +mkdir -p ${RPM_BUILD_DIR}%{_include_dir} +mkdir -p ${RPM_BUILD_DIR}%{_lib_dir} +%ifarch amd64 x86_64 +mkdir -p ${RPM_BUILD_DIR}%{_lib64_dir} +%endif +mkdir -p ${RPM_BUILD_DIR}%{_libexec_dir} +mkdir -p ${RPM_BUILD_DIR}%{_log_dir} +mkdir -p ${RPM_BUILD_DIR}%{_conf_dir} +mkdir -p ${RPM_BUILD_DIR}%{_man_dir} +mkdir -p ${RPM_BUILD_DIR}%{_pid_dir} +mkdir -p ${RPM_BUILD_DIR}%{_sbin_dir} +mkdir -p ${RPM_BUILD_DIR}%{_share_dir} +mkdir -p ${RPM_BUILD_DIR}%{_var_dir} +mkdir -p ${RPM_BUILD_DIR}/etc/init.d + +cp ${RPM_BUILD_DIR}/%{_final_name}/src/packages/rpm/init.d/zookeeper ${RPM_BUILD_DIR}/etc/init.d/zookeeper +cp ${RPM_BUILD_DIR}/%{_final_name}/src/packages/update-zookeeper-env.sh ${RPM_BUILD_DIR}/%{_final_name}/sbin/update-zookeeper-env.sh +chmod 0755 ${RPM_BUILD_DIR}/%{_final_name}/sbin/* +chmod 0755 ${RPM_BUILD_DIR}/etc/init.d/zookeeper + +######################### +#### INSTALL SECTION #### +######################### +%install +pushd ${RPM_BUILD_DIR} +mv ${RPM_BUILD_DIR}/%{_final_name}/bin/* ${RPM_BUILD_DIR}%{_bin_dir} +mv ${RPM_BUILD_DIR}/%{_final_name}/libexec/* ${RPM_BUILD_DIR}%{_libexec_dir} +mv ${RPM_BUILD_DIR}/%{_final_name}/share/zookeeper/* ${RPM_BUILD_DIR}%{_share_dir} +mv ${RPM_BUILD_DIR}/%{_final_name}/conf/* ${RPM_BUILD_DIR}%{_conf_dir} +mv ${RPM_BUILD_DIR}/%{_final_name}/sbin/* ${RPM_BUILD_DIR}%{_sbin_dir} +cp -f ${RPM_BUILD_DIR}%{_conf_dir}/zoo_sample.cfg ${RPM_BUILD_DIR}%{_conf_dir}/zoo.cfg +popd ${RPM_BUILD_DIR} +rm -rf ${RPM_BUILD_DIR}/%{_final_name} + +%pre +getent group hadoop 2>/dev/null >/dev/null || /usr/sbin/groupadd -r hadoop + +/usr/sbin/useradd --comment "ZooKeeper" --shell /bin/bash -M -r --groups hadoop --home %{_share_dir} zookeeper 2> /dev/null || : + +%post +bash ${RPM_INSTALL_PREFIX0}/sbin/update-zookeeper-env.sh \ + --prefix=${RPM_INSTALL_PREFIX0} \ + --conf-dir=${RPM_INSTALL_PREFIX1} \ + --log-dir=${RPM_INSTALL_PREFIX2} \ + --pid-dir=${RPM_INSTALL_PREFIX3} \ + --var-dir=${RPM_INSTALL_PREFIX4} + +%preun +bash ${RPM_INSTALL_PREFIX0}/sbin/update-zookeeper-env.sh \ + --prefix=${RPM_INSTALL_PREFIX0} \ + --conf-dir=${RPM_INSTALL_PREFIX1} \ + --log-dir=${RPM_INSTALL_PREFIX2} \ + --pid-dir=${RPM_INSTALL_PREFIX3} \ + --var-dir=${RPM_INSTALL_PREFIX4} \ + --uninstall + +%files +%defattr(-,root,root) +%attr(0755,root,hadoop) %{_log_dir} +%attr(0775,root,hadoop) %{_pid_dir} +%attr(0775,root,hadoop) /etc/init.d/zookeeper +%config(noreplace) %{_conf_dir}/* +%{_prefix} + +%post lib +/sbin/ldconfig + +%files lib +%defattr(-,root,root) +%{_prefix}/lib/* +%{_prefix}/bin Added: zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh (added) +++ zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh Mon Aug 29 21:26:44 2011 @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +export JAVA_HOME=${JAVA_HOME} +export ZOO_LOG_DIR=${LOG_DIR} Added: zookeeper/trunk/src/packages/update-zookeeper-env.sh URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/update-zookeeper-env.sh?rev=1163014&view=auto ============================================================================== --- zookeeper/trunk/src/packages/update-zookeeper-env.sh (added) +++ zookeeper/trunk/src/packages/update-zookeeper-env.sh Mon Aug 29 21:26:44 2011 @@ -0,0 +1,163 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script configures zookeeper-env.sh and zoo.cfg. + +usage() { + echo " +usage: $0 + Required parameters: + --prefix=PREFIX path to install into + + Optional parameters: + --arch=i386 OS Architecture + --conf-dir=/etc/zookeeper Configuration directory + --log-dir=/var/log/zookeeper Log directory + --pid-dir=/var/run PID file location + " + exit 1 +} + +template_generator() { + REGEX='(\$\{[a-zA-Z_][a-zA-Z_0-9]*\})' + cat $1 | + while read line ; do + while [[ "$line" =~ $REGEX ]] ; do + LHS=${BASH_REMATCH[1]} + RHS="$(eval echo "\"$LHS\"")" + line=${line//$LHS/$RHS} + done + echo $line >> $2 + done +} + +OPTS=$(getopt \ + -n $0 \ + -o '' \ + -l 'arch:' \ + -l 'prefix:' \ + -l 'conf-dir:' \ + -l 'log-dir:' \ + -l 'pid-dir:' \ + -l 'var-dir:' \ + -l 'uninstall' \ + -- "$@") + +if [ $? != 0 ] ; then + usage +fi + +eval set -- "${OPTS}" +while true ; do + case "$1" in + --arch) + ARCH=$2 ; shift 2 + ;; + --prefix) + PREFIX=$2 ; shift 2 + ;; + --log-dir) + LOG_DIR=$2 ; shift 2 + ;; + --lib-dir) + LIB_DIR=$2 ; shift 2 + ;; + --conf-dir) + CONF_DIR=$2 ; shift 2 + ;; + --pid-dir) + PID_DIR=$2 ; shift 2 + ;; + --uninstall) + UNINSTALL=1; shift + ;; + --var-dir) + VAR_DIR=$2 ; shift 2 + ;; + --) + shift ; break + ;; + *) + echo "Unknown option: $1" + usage + exit 1 + ;; + esac +done + +for var in PREFIX; do + if [ -z "$(eval "echo \$$var")" ]; then + echo Missing param: $var + usage + fi +done + +ARCH=${ARCH:-i386} +CONF_DIR=${CONF_DIR:-$PREFIX/etc/zookeeper} +LIB_DIR=${LIB_DIR:-$PREFIX/lib} +LOG_DIR=${LOG_DIR:-$PREFIX/var/log} +PID_DIR=${PID_DIR:-$PREFIX/var/run} +VAR_DIR=${VAR_DIR:-$PREFIX/var/lib} +UNINSTALL=${UNINSTALL:-0} + +if [ "${ARCH}" != "i386" ]; then + LIB_DIR=${LIB_DIR}64 +fi + +if [ "${UNINSTALL}" -eq "1" ]; then + # Remove symlinks + if [ -e ${PREFIX}/etc/zookeeper ]; then + rm -f ${PREFIX}/etc/zookeeper + fi +else + # Create symlinks + if [ ${CONF_DIR} != ${PREFIX}/etc/zookeeper ]; then + mkdir -p ${PREFIX}/etc + ln -sf ${CONF_DIR} ${PREFIX}/etc/zookeeper + fi + + mkdir -p ${LOG_DIR} + chown zookeeper:hadoop ${LOG_DIR} + chmod 755 ${LOG_DIR} + + if [ ! -d ${PID_DIR} ]; then + mkdir -p ${PID_DIR} + chown zookeeper:hadoop ${PID_DIR} + chmod 755 ${PID_DIR} + fi + + if [ ! -d ${VAR_DIR} ]; then + mkdir -p ${VAR_DIR}/data + chown -R zookeeper:hadoop ${VAR_DIR} + chmod -R 755 ${VAR_DIR} + fi + + TFILE="/tmp/$(basename $0).$$.tmp" + if [ -z "${JAVA_HOME}" ]; then + if [ -e /etc/debian_version ]; then + JAVA_HOME=/usr/lib/jvm/java-6-sun/jre + else + JAVA_HOME=/usr/java/default + fi + fi + template_generator ${PREFIX}/share/zookeeper/templates/conf/zookeeper-env.sh $TFILE + cp ${TFILE} ${CONF_DIR}/zookeeper-env.sh + rm -f ${TFILE} + template_generator ${PREFIX}/share/zookeeper/templates/conf/zoo.cfg $TFILE + cp ${TFILE} ${CONF_DIR}/zoo.cfg + rm -f ${TFILE} +fi Modified: zookeeper/trunk/src/recipes/build-recipes.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/build-recipes.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/recipes/build-recipes.xml (original) +++ zookeeper/trunk/src/recipes/build-recipes.xml Mon Aug 29 21:26:44 2011 @@ -122,8 +122,8 @@ - - + @@ -139,6 +139,21 @@ + + + + + + + + + + + + + + + Modified: zookeeper/trunk/src/recipes/build.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/build.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/recipes/build.xml (original) +++ zookeeper/trunk/src/recipes/build.xml Mon Aug 29 21:26:44 2011 @@ -59,4 +59,21 @@ + + + + + + + + + + + + + + + + + Modified: zookeeper/trunk/src/recipes/lock/build.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/lock/build.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/recipes/lock/build.xml (original) +++ zookeeper/trunk/src/recipes/lock/build.xml Mon Aug 29 21:26:44 2011 @@ -112,14 +112,14 @@ - + - - + + - - + + Modified: zookeeper/trunk/src/recipes/queue/build.xml URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/queue/build.xml?rev=1163014&r1=1163013&r2=1163014&view=diff ============================================================================== --- zookeeper/trunk/src/recipes/queue/build.xml (original) +++ zookeeper/trunk/src/recipes/queue/build.xml Mon Aug 29 21:26:44 2011 @@ -112,14 +112,14 @@ - + - - + + - - + +