Skip to content

Instantly share code, notes, and snippets.

@BackSlasher
Created April 29, 2015 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BackSlasher/7510adb69c73dbee7894 to your computer and use it in GitHub Desktop.
Save BackSlasher/7510adb69c73dbee7894 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# (c) Copyright 2009 Cloudera, Inc.
#
# Licensed 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 thrift
#
# chkconfig: 2345 90 10
# description: Hbase thrift
#
# Modified by BackSlasher (http://backslasher.net)
source /etc/rc.d/init.d/functions
RETVAL=0
desc="Hbase thrift daemon"
export HBASE_PID_DIR=<%=@piddir%>
command=thrift
HBASE_IDENT_STRING=<%=@identity%>
pid=$HBASE_PID_DIR/hbase-$HBASE_IDENT_STRING-$command.pid
start() {
echo -n $"Starting $desc (hbase-thrift): "
daemon --pidfile $pid --user <%= @user %> <%= @hbase_home %>/bin/hbase-daemon.sh --config "<%= @hbase_home %>/conf" start thrift <%= "-p #{@port}" if @port %>
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/hbase-thrift
return $RETVAL
}
stop() {
echo -n $"Stopping $desc (hbase-thrift): "
daemon --pidfile $pid --user <%= @user %> <%= @hbase_home %>/bin/hbase-daemon.sh --config "<%= @hbase_home %>/conf" stop thrift
RETVAL=$?
sleep 5
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hbase-thrift
}
restart() {
stop
start
}
condrestart(){
[ -e /var/lock/subsys/hbase-thrift ] && restart || :
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart|try-restart)
condrestart
;;
status)
status -p $pid java
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|try-restart}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment