BIGTOP-936. Use init script templates for HBase.

Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/d0aafdf2
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/d0aafdf2
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/d0aafdf2

Branch: refs/heads/master
Commit: d0aafdf23d62ba27f7629fe07dde0625146ede80
Parents: 2fc2307
Author: Sean Mackrory <[email protected]>
Authored: Thu Apr 25 08:55:48 2013 -0700
Committer: Roman Shaposhnik <[email protected]>
Committed: Wed May 1 18:20:15 2013 -0700

----------------------------------------------------------------------
 bigtop-packages/src/common/hbase/hbase.svc         |   81 ++++++
 .../src/deb/hbase/install_init_scripts.sh          |   18 +-
 bigtop-packages/src/deb/hbase/service-init.d.tpl   |  219 ---------------
 bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh     |  192 -------------
 .../src/rpm/hbase/SOURCES/hbase.sh.suse            |  138 ---------
 bigtop-packages/src/rpm/hbase/SPECS/hbase.spec     |   26 +--
 bigtop-packages/src/templates/init.d.tmpl          |    2 +-
 7 files changed, 96 insertions(+), 580 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/common/hbase/hbase.svc
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hbase/hbase.svc 
b/bigtop-packages/src/common/hbase/hbase.svc
new file mode 100644
index 0000000..c3a9d16
--- /dev/null
+++ b/bigtop-packages/src/common/hbase/hbase.svc
@@ -0,0 +1,81 @@
+# 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.
+
+DAEMON="hbase-@HBASE_DAEMON@"
+DESC="HBase @HBASE_DAEMON@ daemon"
+EXEC_PATH="/usr/lib/hbase/bin/hbase-daemon.sh"
+SVC_USER="hbase"
+DAEMON_FLAGS=""
+CONF_DIR="/etc/hbase/conf"
+PIDFILE="/var/run/hbase/hbase-${DAEMON}.pid"
+LOCKDIR="/var/lock/subsys"
+LOCKFILE="${DAEMON}"
+
+generate_functions() {
+cat <<'__EOT__'
+
+hbase_env() {
+    export HBASE_HOME=/usr/lib/hbase
+    . /etc/default/hbase
+}
+
+__EOT__
+}
+
+generate_start() {
+
+cat <<'__EOT__'
+start() {
+    hbase_env
+
+    [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED
+    log_success_msg "Starting $DESC (${DAEMON}): "
+
+    checkstatusofproc
+    status=$?
+    if [ "$status" -eq "$STATUS_RUNNING" ]; then
+        log_success_msg "${DESC} is running"
+        exit 0
+    fi
+
+    su -s /bin/sh hbase -c "${EXEC_PATH} start @HBASE_DAEMON@"
+
+    checkstatusofproc
+    RETVAL=$?
+    [ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE
+    return $RETVAL
+}
+__EOT__
+
+}
+
+generate_stop() {
+
+cat <<'__EOT__'
+stop() {
+    hbase_env
+
+    log_success_msg "Stopping $DESC (${DAEMON}): "
+    su -s /bin/sh hbase -c "${EXEC_PATH} stop @HBASE_DAEMON@"
+    sleep 3
+    RETVAL=$?
+
+    [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
+    return $RETVAL
+}
+__EOT__
+
+}
+

http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/deb/hbase/install_init_scripts.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hbase/install_init_scripts.sh 
b/bigtop-packages/src/deb/hbase/install_init_scripts.sh
index 1f3c151..07e8f21 100755
--- a/bigtop-packages/src/deb/hbase/install_init_scripts.sh
+++ b/bigtop-packages/src/deb/hbase/install_init_scripts.sh
@@ -17,26 +17,20 @@
 
 SRC_PKG=hbase
 for node in master regionserver rest thrift ; do
-    case $service in
-        master) chkconfig="2345 85 15" ;;
-        thrift) chkconfig="2345 86 14" ;;
-        regionserver) chkconfig="2345 87 13" ;;
-        rest) chkconfig="2345 88 12" ;;
-        *) chkconfig="2345 89 13" ;;
-    esac
     service_pkgdir=debian/$SRC_PKG-$node
     debdir=$service_pkgdir/DEBIAN
-    template="debian/service-init.d.tpl"
+    mkdir -p $service_pkgdir/etc/init.d/ $debdir
     if [ "$node" == "regionserver" ] ; then
         # Region servers start from a different template that allows
         # them to run multiple concurrent instances of the daemon
-        template="debian/regionserver-init.d.tpl"
+        template=debian/regionserver-init.d.tpl
         sed -i -e "s|@INIT_DEFAULT_START@|2 3 4 5|" $template
         sed -i -e "s|@INIT_DEFAULT_STOP@|0 1 6|" $template
+        sed -e "s|@HBASE_DAEMON@|$node|" -e "s|@CHKCONFIG@|2345 87 13|" 
$template > $service_pkgdir/etc/init.d/$SRC_PKG-$node
+    else
+        sed -e "s|@HBASE_DAEMON@|$node|" debian/hbase.svc > 
debian/hbase-$node.svc
+        bash debian/init.d.tmpl debian/hbase-$node.svc deb 
$service_pkgdir/etc/init.d/$SRC_PKG-$node
     fi
-
-    mkdir -p $service_pkgdir/etc/init.d/ $debdir
-    sed -e "s|@HBASE_DAEMON@|$node|" -e "s|@CHKCONFIG@|$chkconfig|" $template 
> $service_pkgdir/etc/init.d/$SRC_PKG-$node
     sed -e "s|@HBASE_DAEMON@|$node|" debian/service-postinst.tpl > 
$debdir/postinst
     sed -e "s|@HBASE_DAEMON@|$node|" debian/service-postrm.tpl > $debdir/postrm
     echo /etc/init.d/$SRC_PKG-$node > $debdir/conffiles

http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/deb/hbase/service-init.d.tpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hbase/service-init.d.tpl 
b/bigtop-packages/src/deb/hbase/service-init.d.tpl
deleted file mode 100644
index 9260c71..0000000
--- a/bigtop-packages/src/deb/hbase/service-init.d.tpl
+++ /dev/null
@@ -1,219 +0,0 @@
-#! /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.
-
-# skeleton  example file to build /etc/init.d/ scripts.
-#    This file should be used to construct scripts for /etc/init.d.
-#
-#    Written by Miquel van Smoorenburg <[email protected]>.
-#    Modified for Debian
-#    by Ian Murdock <[email protected]>.
-#               Further changes by Javier Fernandez-Sanguino <[email protected]>
-#
-# Version:  @(#)skeleton  1.9  26-Feb-2001  [email protected]
-#
-# chkconfig: @CHKCONFIG@
-# description: Summary: HBase is the Hadoop database. Use it when you
-# need random, realtime read/write access to your Big Data. This project's
-# goal is the hosting of very large tables -- billions of rows X millions
-# of columns -- atop clusters of commodity hardware.
-# processname: HBase
-#
-### BEGIN INIT INFO
-# Provides:          hbase-@HBASE_DAEMON@
-# Required-Start:    $network $local_fs $remote_fs
-# Required-Stop:     $remote_fs
-# Should-Start:      $named
-# Should-Stop:
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: Hadoop HBase @HBASE_DAEMON@ daemon
-### END INIT INFO
-
-set -e
-
-. /etc/default/hadoop
-
-# Our default HBASE_HOME and HBASE_PID_DIR
-export HBASE_HOME=/usr/lib/hbase
-export HBASE_PID_DIR=/var/run/hbase
-
-# Include HBase defaults if available
-if [ -f /etc/default/hbase ] ; then
-  . /etc/default/hbase
-fi
-
-# Autodetect JAVA_HOME if not defined                                          
                                                                        
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-if [ -z "$HBASE_PID_DIR" -o -z "$HBASE_HOME" ]; then
-  echo No HBASE_HOME or HBASE_PID_DIR set.
-  exit 1
-fi
-
-
-install -d -m 0755 -o hbase -g hbase ${HBASE_PID_DIR}
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON_SCRIPT=$HBASE_HOME/bin/hbase-daemon.sh
-NAME=hbase-@HBASE_DAEMON@
-DESC="Hadoop HBase @HBASE_DAEMON@ daemon"
-PID_FILE=$HBASE_PID_DIR/hbase-hbase-@[email protected]
-
-
-DODTIME=3                   # Time to wait for the server to die, in seconds
-                            # If this value is set too low you might not
-                            # let some servers to die gracefully and
-                            # 'restart' will not work
-
-# Checks if the given pid represents a live process.
-# Returns 0 if the pid is a live process, 1 otherwise
-hbase_is_process_alive() {
-  local pid="$1" 
-  ps -fp $pid | grep $pid | grep @HBASE_DAEMON@ > /dev/null 2>&1
-}
-
-# Check if the process associated to a pidfile is running.
-# Return 0 if the pidfile exists and the process is running, 1 otherwise
-hbase_check_pidfile() {
-  local pidfile="$1" # IN
-  local pid
-
-  pid=`cat "$pidfile" 2>/dev/null`
-  if [ "$pid" = '' ]; then
-    # The file probably does not exist or is empty. 
-    return 1
-  fi
-  
-  set -- $pid
-  pid="$1"
-
-  hbase_is_process_alive $pid
-}
-
-# Kill the process associated to a pidfile
-hbase_stop_pidfile() {
-   local pidfile="$1" # IN
-   local pid
-
-   pid=`cat "$pidfile" 2>/dev/null`
-   if [ "$pid" = '' ]; then
-      # The file probably does not exist or is empty. Success
-      return 0
-   fi
-   
-   set -- $pid
-   pid="$1"
-
-   # First try the easy way
-   if hbase_process_kill "$pid" 15; then
-      return 0
-   fi
-
-   # Otherwise try the hard way
-   if hbase_process_kill "$pid" 9; then
-      return 0
-   fi
-
-   return 1
-}
-
-hbase_process_kill() {
-    local pid="$1"    # IN
-    local signal="$2" # IN
-    local second
-
-    kill -$signal $pid 2>/dev/null
-
-   # Wait a bit to see if the dirty job has really been done
-    for second in 0 1 2 3 4 5 6 7 8 9 10; do
-        if hbase_is_process_alive "$pid"; then
-         # Success
-            return 0
-        fi
-
-        sleep 1
-    done
-
-   # Timeout
-    return 1
-}
-
-
-start() {
-    su -s /bin/sh hbase -c "$DAEMON_SCRIPT start @HBASE_DAEMON@"
-}
-stop() {
-    su -s /bin/sh hbase -c "$DAEMON_SCRIPT stop @HBASE_DAEMON@"
-}
-
-
-case "$1" in
-  start)
-        echo -n "Starting $DESC: "
-        start
-        if hbase_check_pidfile $PID_FILE ; then
-            echo "$NAME."
-        else
-            echo "ERROR."
-        fi
-  ;;
-  stop)
-        echo -n "Stopping $DESC: "
-        stop
-        if hbase_check_pidfile $PID_FILE ; then
-            echo 'ERROR'
-        else
-            echo "$NAME."
-        fi
-  ;;
-  force-stop)
-        echo -n "Forcefully stopping $DESC: "
-        hbase_stop_pidfile $PID_FILE
-        if hbase_check_pidfile $PID_FILE ; then
-            echo "$NAME."
-        else
-            echo " ERROR."
-        fi
-  ;;
-  force-reload)
-  # check wether $DAEMON is running. If so, restart
-        hbase_check_pidfile $PID_FILE && $0 restart
-  ;;
-  restart)
-        echo -n "Restarting $DESC: "
-        stop
-        [ -n "$DODTIME" ] && sleep $DODTIME
-        $0 start
-  ;;
-  status)
-    echo -n "$NAME is "
-    if hbase_check_pidfile $PID_FILE ;  then
-        echo "running"
-    else
-        echo "not running."
-        exit 1
-    fi
-    ;;
-  *)
-  N=/etc/init.d/$NAME
-  # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
-  echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
-  exit 1
-  ;;
-esac
-
-exit 0

http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh 
b/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh
deleted file mode 100755
index 3cdcea4..0000000
--- a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/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.
-#
-# chkconfig: @CHKCONFIG@
-# description: Summary: HBase is the Hadoop database. Use it when you
-# need random, realtime read/write access to your Big Data. This project's
-# goal is the hosting of very large tables -- billions of rows X millions
-# of columns -- atop clusters of commodity hardware.
-# processname: HBase
-# pidfile: /usr/lib/hbase/pids/hadoop_hbase.pid
-### BEGIN INIT INFO
-# Provides:          HBase
-# Required-Start:    $network $local_fs
-# Required-Stop:
-# Should-Start:      $named
-# Should-Stop:
-# Default-Start:     3 4 5
-# Default-Stop:      0 1 2 6
-# Short-Description: HBase
-### END INIT INFO
-set -e
-
-. /etc/default/hadoop
-. /etc/default/hbase
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON_SCRIPT="/usr/lib/hbase/bin/hbase-daemon.sh"
-NAME=HBase
-DESC="HBase daemon"
- 
-install -d -m 0755 -o hbase -g hbase ${HBASE_PID_DIR}
-
-PID_FILE=${HBASE_PID_DIR}/hbase-hbase-@[email protected]
-
-
-
-DODTIME=3
-
-
-hadoop_is_process_alive() {
-    local pid="$1"
-    ps -fp $pid | grep $pid | grep -i @HBASE_DAEMON@ > /dev/null 2>&1
-}
-
-hadoop_check_pidfile() {
-    local pidfile="$1" # IN
-    local pid
-
-    pid=`cat "$pidfile" 2>/dev/null`
-    if [ "$pid" = '' ]; then
-    # The file probably does not exist or is empty.
-       return 1
-    fi
-
-    set -- $pid
-    pid="$1"
-
-    hadoop_is_process_alive $pid
-}
-hadoop_check_pidfile() {
-    local pidfile="$1" # IN
-    local pid
-
-    pid=`cat "$pidfile" 2>/dev/null`
-    if [ "$pid" = '' ]; then
-    # The file probably does not exist or is empty. 
-       return 1
-    fi
-    
-    set -- $pid
-    pid="$1"
-
-    hadoop_is_process_alive $pid
-}
-
-hadoop_process_kill() {
-    local pid="$1"    # IN
-    local signal="$2" # IN
-    local second
-
-    kill -$signal $pid 2>/dev/null
-
-   # Wait a bit to see if the dirty job has really been done
-    for second in 0 1 2 3 4 5 6 7 8 9 10; do
-       if hadoop_is_process_alive "$pid"; then
-         # Success
-           return 0
-       fi
-
-       sleep 1
-    done
-
-   # Timeout
-    return 1
-}
-hadoop_stop_pidfile() {
-    local pidfile="$1" # IN
-    local pid
-
-    pid=`cat "$pidfile" 2>/dev/null`
-    if [ "$pid" = '' ]; then
-      # The file probably does not exist or is empty. Success
-       return 0
-    fi
-    
-    set -- $pid
-    pid="$1"
-
-   # First try the easy way
-    if hadoop_process_kill "$pid" 15; then
-       return 0
-    fi
-
-   # Otherwise try the hard way
-    if hadoop_process_kill "$pid" 9; then
-       return 0
-    fi
-
-    return 1
-}
-
-
-start() {
-    su -s /bin/sh hbase -c "${DAEMON_SCRIPT} start @HBASE_DAEMON@"
-}
-stop() {
-    su -s /bin/sh hbase -c "${DAEMON_SCRIPT} stop @HBASE_DAEMON@"
-}
-
-case "$1" in
-    start)
-       start
-       ;;
-    stop)
-       stop 
-       ;;
-    force-stop)
-        echo -n "Forcefully stopping $DESC: "
-        hadoop_stop_pidfile $PID_FILE
-        if ! hadoop_check_pidfile $PID_FILE ; then
-            echo "$NAME."
-        else
-            echo " ERROR."
-        fi
-       ;;
-    force-reload|condrestart|try-restart)
-  # check wether $DAEMON is running. If so, restart
-        hadoop_check_pidfile $PID_FILE && $0 restart
-       ;;
-    restart|reload)
-        echo -n "Restarting $DESC: "
-        stop
-        [ -n "$DODTIME" ] && sleep $DODTIME
-        $0 start
-       ;;
-    status)
-       echo -n "$NAME is "
-       if hadoop_check_pidfile $PID_FILE ;  then
-           echo "running"
-       else
-           echo "not running."
-           exit 1
-       fi
-       ;;
-
-    *)
-       N=/etc/init.d/$NAME
-  # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
-       echo "Usage: $N 
{start|stop|restart|force-reload|status|force-stop|condrestart|try-restart}" >&2
-
-       exit 1
-       ;;
-esac
-
-exit 0

http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse 
b/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse
deleted file mode 100644
index 5452e00..0000000
--- a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/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.
-#
-# Starts a HBase @HBASE_DAEMON@
-#
-# chkconfig: @CHKCONFIG@
-# description: Summary: HBase is the Hadoop database. Use it when you
-# need random, realtime read/write access to your Big Data. This project's
-# goal is the hosting of very large tables -- billions of rows X millions
-# of columns -- atop clusters of commodity hardware.
-# processname: HBase
-#
-### BEGIN INIT INFO
-# Provides:          HBase-@HBASE_DAEMON@
-# Required-Start:    $syslog $remote_fs
-# Should-Start:
-# Required-Stop:     $syslog $remote_fs
-# Should-Stop:
-# Default-Start:     3 4 5
-# Default-Stop:      0 1 2 6
-# Short-Description: HBase @HBASE_DAEMON@
-### END INIT INFO
-
-. /lib/lsb/init-functions
-. /etc/default/hadoop
-. /etc/default/hbase
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-STATUS_RUNNING=0
-STATUS_DEAD=1
-STATUS_DEAD_AND_LOCK=2
-STATUS_NOT_RUNNING=3
-
-ERROR_PROGRAM_NOT_INSTALLED=5
-
-USER=hbase
-DESC="HBase master daemon"
-DAEMON_SCRIPT="/usr/lib/hbase/bin/hbase-daemon.sh"
-
-if [ -f /usr/lib/hbase/bin/hbase-config.sh ] ; then
-  . /usr/lib/hbase/bin/hbase-config.sh
-fi
-install -d -m 0755 -o $USER -g hbase ${HBASE_PID_DIR}
-
-PID_FILE=${HBASE_PID_DIR}/hbase-hbase-@[email protected]
-LOCKFILE="/var/lock/subsys/hbase-@HBASE_DAEMON@"
-
-
-start() {
-  [ -x $DAEMON_SCRIPT ] || exit $ERROR_PROGRAM_NOT_INSTALLED
-  log_success_msg "Starting $desc (hbase-@HBASE_DAEMON@): "
-  start_daemon -u $USER $DAEMON_SCRIPT start @HBASE_DAEMON@
-  RETVAL=$?
-  echo
-  [ $RETVAL -eq 0 ] && touch $LOCKFILE
-  return $RETVAL
-}
-
-stop() {
-  log_success_msg "Stopping $desc (hbase-@HBASE_DAEMON@): "
-  start_daemon -u $USER $DAEMON_SCRIPT stop @HBASE_DAEMON@
-  RETVAL=$?
-  sleep 5
-  echo
-  [ $RETVAL -eq 0 ] && rm -f $LOCKFILE $PID_FILE
-}
-
-restart() {
-  stop
-  start
-}
-
-checkstatus(){
-  pidofproc -p $PID_FILE java > /dev/null
-  status=$?
-
-  case "$status" in
-    $STATUS_RUNNING)
-      log_success_msg "@HBASE_DAEMON@ is running"
-      ;;
-    $STATUS_DEAD)
-      log_failure_msg "@HBASE_DAEMON@ is dead and pid file exists"
-      ;;
-    $STATUS_DEAD_AND_LOCK)
-      log_failure_msg "@HBASE_DAEMON@ is dead and lock file exists"
-      ;;
-    $STATUS_NOT_RUNNING)
-      log_failure_msg "@HBASE_DAEMON@ is not running"
-      ;;
-    *)
-      log_failure_msg "@HBASE_DAEMON@ status is unknown"
-      ;;
-  esac
-  return $status
-}
-
-condrestart(){
-  [ -e $LOCKFILE ] && restart || :
-}
-
-case "$1" in
-  start)
-    start
-    ;;
-  stop)
-    stop
-    ;;
-  status)
-    checkstatus
-    ;;
-  restart)
-    restart
-    ;;
-  condrestart|try-restart)
-    condrestart
-    ;;
-  *)
-    echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
-    exit 1
-esac
-
-exit $RETVAL

http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec 
b/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
index ee15e4d..37e683b 100644
--- a/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
+++ b/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
@@ -86,8 +86,8 @@ License: APL2
 Source0: %{name}-%{hbase_base_version}.tar.gz
 Source1: do-component-build
 Source2: install_hbase.sh
-Source3: hbase.sh
-Source4: hbase.sh.suse
+Source3: hbase.svc
+Source4: init.d.tmpl
 Source5: hbase.default
 Source6: hbase.nofiles.conf
 Source7: regionserver-init.d.tpl
@@ -259,32 +259,22 @@ ln -s %{_localstatedir}/log/%{name} 
%{buildroot}/%{logs_hbase}
 %__install -d  -m 0755  %{buildroot}/%{_localstatedir}/run/%{name}
 ln -s %{_localstatedir}/run/%{name} %{buildroot}/%{pids_hbase}
 
-%if  %{?suse_version:1}0
-orig_init_file=%{SOURCE4}
-%else
-orig_init_file=%{SOURCE3}
-%endif
-
 for service in %{hbase_services}
 do
-  case $service in
-    master) chkconfig="345 85 15" ;;
-    thrift) chkconfig="345 86 14" ;;
-    regionserver) chkconfig="345 87 13" ;;
-    rest) chkconfig="345 88 12" ;;
-    *) chkconfig="345 89 13" ;;
-  esac
     init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
-    %__cp $orig_init_file $init_file
     if [[ "$service" = "regionserver" ]] ; then
         # Region servers start from a different template that allows
         # them to run multiple concurrent instances of the daemon
         %__cp %{SOURCE7} $init_file
         %__sed -i -e "s|@INIT_DEFAULT_START@|3 4 5|" $init_file
         %__sed -i -e "s|@INIT_DEFAULT_STOP@|0 1 2 6|" $init_file
+        %__sed -i -e "s|@CHKCONFIG@|345 87 13|" $init_file
+        %__sed -i -e "s|@HBASE_DAEMON@|${service}|" $init_file
+    else
+        %__sed -e "s|@HBASE_DAEMON@|${service}|" %{SOURCE3} > 
${RPM_SOURCE_DIR}/hbase-${service}.node
+        bash %{SOURCE4} ${RPM_SOURCE_DIR}/hbase-${service}.node rpm $init_file
     fi
-    %__sed -i -e "s|@CHKCONFIG@|${chkconfig}|" $init_file
-    %__sed -i -e "s|@HBASE_DAEMON@|${service}|" $init_file
+
     chmod 755 $init_file
 done
 

http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/templates/init.d.tmpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/templates/init.d.tmpl 
b/bigtop-packages/src/templates/init.d.tmpl
index 61db5d5..9f51414 100644
--- a/bigtop-packages/src/templates/init.d.tmpl
+++ b/bigtop-packages/src/templates/init.d.tmpl
@@ -21,7 +21,7 @@
 # a mandatory argument of a file containing the configuration for the service. 
 # The argument file should be a valid piece of bash code since it gets directly
 # source into this template. E.g.
-#    $ bash ./init.d.tmpl hadoop-hdfs-namenode.svc > hadoop-hdfs-namenode
+#    $ bash ./init.d.tmpl hadoop-hdfs-namenode.svc rpm hadoop-hdfs-namenode
 # 
 # You must declare the following in your .svc configuration file:
 #     DAEMON="name of the resulting init.d script"

Reply via email to