From 18a053d37b16c10ca74b8e3ea2068740cd9904c7 Mon Sep 17 00:00:00 2001 From: Wayne Schneider Date: Mon, 1 Aug 2016 16:39:47 -0500 Subject: [PATCH] Debian packaging for zookeeper. --- debian/.gitignore | 1 + debian/control | 9 ++ debian/dirs | 6 -- debian/install | 3 - debian/links | 1 - debian/lui-zookeeper.default | 118 -------------------------- debian/lui-zookeeper.init | 139 ------------------------------- debian/masterkey-lui-solr5.dirs | 6 ++ debian/masterkey-lui-solr5.install | 4 + debian/masterkey-lui-solr5.links | 1 + debian/masterkey-lui-solr5.postinst | 28 +++++++ debian/masterkey-lui-solr5.postrm | 32 +++++++ debian/masterkey-lui-zookeeper.default | 118 ++++++++++++++++++++++++++ debian/masterkey-lui-zookeeper.dirs | 6 ++ debian/masterkey-lui-zookeeper.init | 139 +++++++++++++++++++++++++++++++ debian/masterkey-lui-zookeeper.install | 3 + debian/masterkey-lui-zookeeper.postinst | 33 ++++++++ debian/masterkey-lui-zookeeper.postrm | 31 +++++++ debian/masterkey-lui-zookeeper.preinst | 25 ++++++ debian/masterkey-lui-zookeeper.prerm | 23 +++++ debian/postinst | 28 ------- debian/postrm | 17 ---- dev-deploy-ha/zookeeper.yml | 8 +- 23 files changed, 463 insertions(+), 316 deletions(-) delete mode 100644 debian/dirs delete mode 100644 debian/install delete mode 100644 debian/links delete mode 100755 debian/lui-zookeeper.default delete mode 100755 debian/lui-zookeeper.init create mode 100644 debian/masterkey-lui-solr5.dirs create mode 100644 debian/masterkey-lui-solr5.install create mode 100644 debian/masterkey-lui-solr5.links create mode 100755 debian/masterkey-lui-solr5.postinst create mode 100755 debian/masterkey-lui-solr5.postrm create mode 100755 debian/masterkey-lui-zookeeper.default create mode 100644 debian/masterkey-lui-zookeeper.dirs create mode 100755 debian/masterkey-lui-zookeeper.init create mode 100644 debian/masterkey-lui-zookeeper.install create mode 100644 debian/masterkey-lui-zookeeper.postinst create mode 100644 debian/masterkey-lui-zookeeper.postrm create mode 100644 debian/masterkey-lui-zookeeper.preinst create mode 100644 debian/masterkey-lui-zookeeper.prerm delete mode 100755 debian/postinst delete mode 100755 debian/postrm diff --git a/debian/.gitignore b/debian/.gitignore index 4c37f87..4f211f1 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,3 +1,4 @@ files *.substvars *.log +*.debhelper diff --git a/debian/control b/debian/control index c3e2c51..7cdfcc4 100644 --- a/debian/control +++ b/debian/control @@ -15,3 +15,12 @@ Description: Local Unified Index (Solr) The Local Unified Index is a index that contains multiple logical indexes (subdatabases). The underlying index is a Solr/Lucene 5 index configured to use a specific LUI schema. + +Package: masterkey-lui-zookeeper +Architecture: all +Depends: openjdk-7-jdk, ${misc:Depends} +Description: Local Unified Index (Zookeeper) + The Local Unified Index is a index that contains multiple logical indexes + (subdatabases). The underlying index is a Solr/Lucene 5 index configured + to use a specific LUI schema. This package provides an installation + of Apache Zookeeper suitable for a lui-solr cluster. diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index fae317f..0000000 --- a/debian/dirs +++ /dev/null @@ -1,6 +0,0 @@ -etc/default -usr/share/masterkey/lui -usr/share/doc/masterkey-lui-solr5 -etc/masterkey/lui/solr -var/log/masterkey/lui -var/lib/masterkey/lui/solr/lui diff --git a/debian/install b/debian/install deleted file mode 100644 index 21ad2d9..0000000 --- a/debian/install +++ /dev/null @@ -1,3 +0,0 @@ -dist usr/share/masterkey/lui -conf/solr/* etc/masterkey/lui/solr -doc/* usr/share/doc/masterkey-lui-solr5 diff --git a/debian/links b/debian/links deleted file mode 100644 index 1d33fc4..0000000 --- a/debian/links +++ /dev/null @@ -1 +0,0 @@ -etc/masterkey/lui/solr/lui-solr.in.sh etc/default/lui-solr.in.sh \ No newline at end of file diff --git a/debian/lui-zookeeper.default b/debian/lui-zookeeper.default deleted file mode 100755 index 3b6d4bd..0000000 --- a/debian/lui-zookeeper.default +++ /dev/null @@ -1,118 +0,0 @@ -#!/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 should be sourced into other zookeeper -# scripts to setup the env variables - -# We use ZOOCFGDIR if defined, -# otherwise we use /etc/zookeeper -# or the conf directory that is -# a sibling of this script's directory - -ZOOBINDIR=/usr/share/masterkey/lui/zookeeper/bin -ZOOKEEPER_PREFIX="${ZOOBINDIR}/.." -ZOOCFGDIR=/etc/masterkey/lui/zookeeper -ZOO_LOG_DIR=/var/log/masterkey/lui -ZOOPIDDIR=/var/lib/masterkey/lui -ZOOPIDFILE=${ZOOPIDDIR}/zookeeper_server.pid - -JMXDISABLE=1 -JVMFLAGS="-Xmx512m -Xms256m" - -if [ "x$ZOOCFGDIR" = "x" ] -then - if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then - ZOOCFGDIR="$ZOOBINDIR/../conf" - else - ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper" - fi -fi - -if [ "x$ZOOCFG" = "x" ] -then - ZOOCFG="zoo.cfg" -fi - -ZOOCFG="$ZOOCFGDIR/$ZOOCFG" - -if [ -f "$ZOOCFGDIR/java.env" ] -then - . "$ZOOCFGDIR/java.env" -fi - -if [ "x${ZOO_LOG_DIR}" = "x" ] -then - ZOO_LOG_DIR="." -fi - -if [ "x${ZOO_LOG4J_PROP}" = "x" ] -then - ZOO_LOG4J_PROP="INFO,CONSOLE" -fi - -if [ "$JAVA_HOME" != "" ]; then - JAVA="$JAVA_HOME/bin/java" -else - JAVA=java -fi - -#add the zoocfg dir to classpath -CLASSPATH="$ZOOCFGDIR:$CLASSPATH" - -for i in "$ZOOBINDIR"/../src/java/lib/*.jar -do - CLASSPATH="$i:$CLASSPATH" -done - -#make it work in the binary package -if [ -e "${ZOOKEEPER_PREFIX}"/share/zookeeper/zookeeper-*.jar ]; then - for i in "$ZOOKEEPER_PREFIX"/share/zookeeper/*.jar - do - CLASSPATH="$i:$CLASSPATH" - done -else - #release tarball format - for i in "$ZOOBINDIR"/../zookeeper-*.jar - do - CLASSPATH="$i:$CLASSPATH" - done - for i in "$ZOOBINDIR"/../lib/*.jar - do - CLASSPATH="$i:$CLASSPATH" - done -fi - -#make it work for developers -for d in "$ZOOBINDIR"/../build/lib/*.jar -do - CLASSPATH="$d:$CLASSPATH" -done - -#make it work for developers -CLASSPATH="$ZOOBINDIR/../build/classes:$CLASSPATH" - -case "`uname`" in - CYGWIN*) cygwin=true ;; - *) cygwin=false ;; -esac - -if $cygwin -then - CLASSPATH=`cygpath -wp "$CLASSPATH"` -fi - -#echo "CLASSPATH=$CLASSPATH" diff --git a/debian/lui-zookeeper.init b/debian/lui-zookeeper.init deleted file mode 100755 index b9147d2..0000000 --- a/debian/lui-zookeeper.init +++ /dev/null @@ -1,139 +0,0 @@ -#! /bin/sh - -# init script for lui-zookeeper - -# 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: lui-zookeeper -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: -# Short-Description: Apache ZooKeeper server for Index Data Local Unified Index (LUI) -### END INIT INFO - -set -e - -# /etc/init.d/lui-zookeeper: start and stop the Apache ZooKeeper daemon - -umask 022 - -. /etc/default/lui-zookeeper - -. /lib/lsb/init-functions - -check_privsep_dir() { - # Create the PrivSep empty dir if necessary - if [ ! -d ${ZOOPIDDIR} ]; then - mkdir -p ${ZOOPIDDIR} - chown lui-solr:lui-solr ${ZOOPIDDIR} - chmod 0775 ${ZOOPIDDIR} - fi -} - -# 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/masterkey/lui/zookeeper/zookeeper_not_to_be_run exists - if [ -e /etc/masterkey/lui/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 - check_privsep_dir - log_daemon_msg "Starting Apache ZooKeeper server" "zookeeper" - if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c lui-solr -x ${ZOOKEEPER_PREFIX}/bin/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 lui-solr -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 lui-solr -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/lui-zookeeper {start|stop|restart|try-restart|status}" - exit 1 -esac - -exit 0 diff --git a/debian/masterkey-lui-solr5.dirs b/debian/masterkey-lui-solr5.dirs new file mode 100644 index 0000000..a689e3d --- /dev/null +++ b/debian/masterkey-lui-solr5.dirs @@ -0,0 +1,6 @@ +etc/default +usr/share/masterkey/lui/dist +usr/share/doc/masterkey-lui-solr5 +etc/masterkey/lui/solr +var/log/masterkey/lui +var/lib/masterkey/lui/solr/lui diff --git a/debian/masterkey-lui-solr5.install b/debian/masterkey-lui-solr5.install new file mode 100644 index 0000000..023d453 --- /dev/null +++ b/debian/masterkey-lui-solr5.install @@ -0,0 +1,4 @@ +dist/solr-5*.tgz usr/share/masterkey/lui/dist +dist/install_solr_service.sh usr/share/masterkey/lui/dist +conf/solr/* etc/masterkey/lui/solr +doc/* usr/share/doc/masterkey-lui-solr5 diff --git a/debian/masterkey-lui-solr5.links b/debian/masterkey-lui-solr5.links new file mode 100644 index 0000000..1d33fc4 --- /dev/null +++ b/debian/masterkey-lui-solr5.links @@ -0,0 +1 @@ +etc/masterkey/lui/solr/lui-solr.in.sh etc/default/lui-solr.in.sh \ No newline at end of file diff --git a/debian/masterkey-lui-solr5.postinst b/debian/masterkey-lui-solr5.postinst new file mode 100755 index 0000000..0eb3fcf --- /dev/null +++ b/debian/masterkey-lui-solr5.postinst @@ -0,0 +1,28 @@ +#!/bin/sh -e + +case "$1" in + configure|upgrade) + # Create the solr user + adduser --system --shell /bin/bash --group --disabled-password --home /var/lib/masterkey/lui lui-solr + # Set directory permissions + chown -R lui-solr /var/lib/masterkey/lui + chown -R lui-solr /var/log/masterkey/lui + chown -R lui-solr /etc/masterkey/lui/solr/solr-home + # Run Solr installation script + /usr/share/masterkey/lui/dist/install_solr_service.sh /usr/share/masterkey/lui/dist/solr-5.5.1.tgz -d /var/lib/masterkey/lui -i /usr/share/masterkey/lui -s lui-solr -u lui-solr -f + # Remove extra files created by Solr installation + rm -f /var/lib/masterkey/lui/log4j.properties + rm -rf /var/lib/masterkey/lui/logs + rm -rf /var/lib/masterkey/lui/data + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument '$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/masterkey-lui-solr5.postrm b/debian/masterkey-lui-solr5.postrm new file mode 100755 index 0000000..49e2e51 --- /dev/null +++ b/debian/masterkey-lui-solr5.postrm @@ -0,0 +1,32 @@ +#!/bin/sh -e + +case "$1" in + purge|remove) + # Remove Solr installation + rm -f /usr/share/masterkey/lui/lui-solr + rm -rf /usr/share/masterkey/lui/solr-* + + # Automatically added by dh_installinit + if [ "$1" = "purge" ] ; then + update-rc.d lui-solr remove >/dev/null + fi + + + # In case this system is running systemd, we make systemd reload the unit files + # to pick up changes. + if [ -d /run/systemd/system ] ; then + systemctl --system daemon-reload >/dev/null || true + fi + # End automatically added section + + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 +esac + +exit 0 diff --git a/debian/masterkey-lui-zookeeper.default b/debian/masterkey-lui-zookeeper.default new file mode 100755 index 0000000..3b6d4bd --- /dev/null +++ b/debian/masterkey-lui-zookeeper.default @@ -0,0 +1,118 @@ +#!/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 should be sourced into other zookeeper +# scripts to setup the env variables + +# We use ZOOCFGDIR if defined, +# otherwise we use /etc/zookeeper +# or the conf directory that is +# a sibling of this script's directory + +ZOOBINDIR=/usr/share/masterkey/lui/zookeeper/bin +ZOOKEEPER_PREFIX="${ZOOBINDIR}/.." +ZOOCFGDIR=/etc/masterkey/lui/zookeeper +ZOO_LOG_DIR=/var/log/masterkey/lui +ZOOPIDDIR=/var/lib/masterkey/lui +ZOOPIDFILE=${ZOOPIDDIR}/zookeeper_server.pid + +JMXDISABLE=1 +JVMFLAGS="-Xmx512m -Xms256m" + +if [ "x$ZOOCFGDIR" = "x" ] +then + if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then + ZOOCFGDIR="$ZOOBINDIR/../conf" + else + ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper" + fi +fi + +if [ "x$ZOOCFG" = "x" ] +then + ZOOCFG="zoo.cfg" +fi + +ZOOCFG="$ZOOCFGDIR/$ZOOCFG" + +if [ -f "$ZOOCFGDIR/java.env" ] +then + . "$ZOOCFGDIR/java.env" +fi + +if [ "x${ZOO_LOG_DIR}" = "x" ] +then + ZOO_LOG_DIR="." +fi + +if [ "x${ZOO_LOG4J_PROP}" = "x" ] +then + ZOO_LOG4J_PROP="INFO,CONSOLE" +fi + +if [ "$JAVA_HOME" != "" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA=java +fi + +#add the zoocfg dir to classpath +CLASSPATH="$ZOOCFGDIR:$CLASSPATH" + +for i in "$ZOOBINDIR"/../src/java/lib/*.jar +do + CLASSPATH="$i:$CLASSPATH" +done + +#make it work in the binary package +if [ -e "${ZOOKEEPER_PREFIX}"/share/zookeeper/zookeeper-*.jar ]; then + for i in "$ZOOKEEPER_PREFIX"/share/zookeeper/*.jar + do + CLASSPATH="$i:$CLASSPATH" + done +else + #release tarball format + for i in "$ZOOBINDIR"/../zookeeper-*.jar + do + CLASSPATH="$i:$CLASSPATH" + done + for i in "$ZOOBINDIR"/../lib/*.jar + do + CLASSPATH="$i:$CLASSPATH" + done +fi + +#make it work for developers +for d in "$ZOOBINDIR"/../build/lib/*.jar +do + CLASSPATH="$d:$CLASSPATH" +done + +#make it work for developers +CLASSPATH="$ZOOBINDIR/../build/classes:$CLASSPATH" + +case "`uname`" in + CYGWIN*) cygwin=true ;; + *) cygwin=false ;; +esac + +if $cygwin +then + CLASSPATH=`cygpath -wp "$CLASSPATH"` +fi + +#echo "CLASSPATH=$CLASSPATH" diff --git a/debian/masterkey-lui-zookeeper.dirs b/debian/masterkey-lui-zookeeper.dirs new file mode 100644 index 0000000..db0d14d --- /dev/null +++ b/debian/masterkey-lui-zookeeper.dirs @@ -0,0 +1,6 @@ +etc/default +usr/share/masterkey/lui/dist +usr/share/doc/masterkey-lui-zookeeper +etc/masterkey/lui/zookeeper +var/log/masterkey/lui +var/lib/masterkey/lui/zookeeper diff --git a/debian/masterkey-lui-zookeeper.init b/debian/masterkey-lui-zookeeper.init new file mode 100755 index 0000000..71a6b18 --- /dev/null +++ b/debian/masterkey-lui-zookeeper.init @@ -0,0 +1,139 @@ +#! /bin/sh + +# init script for lui-zookeeper + +# 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: lui-zookeeper +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Apache ZooKeeper server for Index Data Local Unified Index (LUI) +### END INIT INFO + +set -e + +# /etc/init.d/lui-zookeeper: start and stop the Apache ZooKeeper daemon + +umask 022 + +. /etc/default/masterkey-lui-zookeeper + +. /lib/lsb/init-functions + +check_privsep_dir() { + # Create the PrivSep empty dir if necessary + if [ ! -d ${ZOOPIDDIR} ]; then + mkdir -p ${ZOOPIDDIR} + chown lui-solr:lui-solr ${ZOOPIDDIR} + chmod 0775 ${ZOOPIDDIR} + fi +} + +# 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/masterkey/lui/zookeeper/zookeeper_not_to_be_run exists + if [ -e /etc/masterkey/lui/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 + check_privsep_dir + log_daemon_msg "Starting Apache ZooKeeper server" "zookeeper" + if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c lui-solr -x ${ZOOKEEPER_PREFIX}/bin/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 lui-solr -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 lui-solr -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/lui-zookeeper {start|stop|restart|try-restart|status}" + exit 1 +esac + +exit 0 diff --git a/debian/masterkey-lui-zookeeper.install b/debian/masterkey-lui-zookeeper.install new file mode 100644 index 0000000..d61b36c --- /dev/null +++ b/debian/masterkey-lui-zookeeper.install @@ -0,0 +1,3 @@ +dist/zookeeper-*.tar.gz usr/share/masterkey/lui/dist +conf/zookeeper/* etc/masterkey/lui/zookeeper +doc/* usr/share/doc/masterkey-lui-zookeeper diff --git a/debian/masterkey-lui-zookeeper.postinst b/debian/masterkey-lui-zookeeper.postinst new file mode 100644 index 0000000..df32d43 --- /dev/null +++ b/debian/masterkey-lui-zookeeper.postinst @@ -0,0 +1,33 @@ +#!/bin/sh -e + +case "$1" in + configure|upgrade) + # Set directory permissions + chown -R lui-solr:lui-solr /var/lib/masterkey/lui + chown -R lui-solr:lui-solr /var/log/masterkey/lui + # Unpack zookeeper tarball + cd /usr/share/masterkey/lui + tar xzf dist/zookeeper-3.4.6.tar.gz + ln -s zookeeper-3.4.6 zookeeper + mkdir -p zookeeper/libexec + ln -s /etc/default/masterkey-lui-zookeeper zookeeper/libexec/zkEnv.sh + + # Automatically added by dh_installinit + if [ -x "/etc/init.d/masterkey-lui-zookeeper" ]; then + update-rc.d masterkey-lui-zookeeper defaults >/dev/null + invoke-rc.d masterkey-lui-zookeeper start || exit $? + fi + # End automatically added section + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument '$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/masterkey-lui-zookeeper.postrm b/debian/masterkey-lui-zookeeper.postrm new file mode 100644 index 0000000..5e3d3a5 --- /dev/null +++ b/debian/masterkey-lui-zookeeper.postrm @@ -0,0 +1,31 @@ +#!/bin/sh -e + +case "$1" in + purge|remove) + # Remove Zookeeper installation + rm -f /usr/share/masterkey/lui/zookeeper + rm -rf /usr/share/masterkey/lui/zookeeper-* + + # Automatically added by dh_installinit + if [ "$1" = "purge" ] ; then + update-rc.d masterkey-lui-zookeeper remove >/dev/null + fi + + + # In case this system is running systemd, we make systemd reload the unit files + # to pick up changes. + if [ -d /run/systemd/system ] ; then + systemctl --system daemon-reload >/dev/null || true + fi + # End automatically added section + + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 +esac + +exit 0 diff --git a/debian/masterkey-lui-zookeeper.preinst b/debian/masterkey-lui-zookeeper.preinst new file mode 100644 index 0000000..a4400b6 --- /dev/null +++ b/debian/masterkey-lui-zookeeper.preinst @@ -0,0 +1,25 @@ +#!/bin/sh -e + +case "$1" in + install|upgrade) + # Create the solr user + adduser --system --shell /bin/bash --group --disabled-password --home /var/lib/masterkey/lui lui-solr + + # Automatically added by dh_installinit + if [ -x "/etc/init.d/masterkey-lui-zookeeper" ]; then + invoke-rc.d masterkey-lui-zookeeper stop || exit $? + fi + # End automatically added section + + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument '$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/masterkey-lui-zookeeper.prerm b/debian/masterkey-lui-zookeeper.prerm new file mode 100644 index 0000000..1db84ba --- /dev/null +++ b/debian/masterkey-lui-zookeeper.prerm @@ -0,0 +1,23 @@ +#!/bin/sh -e + +case "$1" in + remove|upgrade|deconfigure) + + # Automatically added by dh_installinit + if [ -x "/etc/init.d/masterkey-lui-zookeeper" ]; then + invoke-rc.d masterkey-lui-zookeeper stop || exit $? + fi + # End automatically added section + + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument '$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/postinst b/debian/postinst deleted file mode 100755 index 0eb3fcf..0000000 --- a/debian/postinst +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -e - -case "$1" in - configure|upgrade) - # Create the solr user - adduser --system --shell /bin/bash --group --disabled-password --home /var/lib/masterkey/lui lui-solr - # Set directory permissions - chown -R lui-solr /var/lib/masterkey/lui - chown -R lui-solr /var/log/masterkey/lui - chown -R lui-solr /etc/masterkey/lui/solr/solr-home - # Run Solr installation script - /usr/share/masterkey/lui/dist/install_solr_service.sh /usr/share/masterkey/lui/dist/solr-5.5.1.tgz -d /var/lib/masterkey/lui -i /usr/share/masterkey/lui -s lui-solr -u lui-solr -f - # Remove extra files created by Solr installation - rm -f /var/lib/masterkey/lui/log4j.properties - rm -rf /var/lib/masterkey/lui/logs - rm -rf /var/lib/masterkey/lui/data - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument '$1'" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/postrm b/debian/postrm deleted file mode 100755 index b11b87e..0000000 --- a/debian/postrm +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -e - -case "$1" in - purge|remove) - # Remove Solr installation - rm -f /usr/share/masterkey/lui/lui-solr - rm -rf /usr/share/masterkey/lui/solr-* - ;; - upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 -esac - -exit 0 diff --git a/dev-deploy-ha/zookeeper.yml b/dev-deploy-ha/zookeeper.yml index dfb0a37..0750019 100644 --- a/dev-deploy-ha/zookeeper.yml +++ b/dev-deploy-ha/zookeeper.yml @@ -52,16 +52,16 @@ - name: Link Zookeeper defaults into /etc/default become: yes - file: src=/vagrant/debian/lui-zookeeper.default path=/etc/default/lui-zookeeper state=link + file: src=/vagrant/debian/masterkey-lui-zookeeper.default path=/etc/default/masterkey-lui-zookeeper state=link - name: Link Zookeeper defaults into /usr/share/masterkey/lui/zookeeper/libexec become: yes - file: src=/etc/default/lui-zookeeper path=/usr/share/masterkey/lui/zookeeper/libexec/zkEnv.sh state=link + file: src=/etc/default/masterkey-lui-zookeeper path=/usr/share/masterkey/lui/zookeeper/libexec/zkEnv.sh state=link - name: Link init script become: yes - file: src=/vagrant/debian/lui-zookeeper.init path=/etc/init.d/lui-zookeeper state=link + file: src=/vagrant/debian/masterkey-lui-zookeeper.init path=/etc/init.d/masterkey-lui-zookeeper state=link - name: Enable and start service become: yes - service: name=lui-zookeeper enabled=yes state=started + service: name=masterkey-lui-zookeeper enabled=yes state=started -- 1.7.10.4