summaryrefslogtreecommitdiff
path: root/system/apache-cassandra/rc.cassandra
diff options
context:
space:
mode:
authorMario Antunes <mariolpantunes@gmail.com>2014-04-26 19:17:33 +0700
committerErik Hanson <erik@slackbuilds.org>2014-04-27 12:18:17 -0500
commit1f150aedcf7f6c8d8a4fc08f7d9e6532014574c4 (patch)
tree9e40e42be6247696fad4bc40c01b7bdc9b955179 /system/apache-cassandra/rc.cassandra
parent01adc3f445c752acba84e1337ab1087546e8c1be (diff)
downloadslackbuilds-1f150aedcf7f6c8d8a4fc08f7d9e6532014574c4.tar.gz
system/apache-cassandra: Updated for version 2.0.7 + new maintainer.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/apache-cassandra/rc.cassandra')
-rw-r--r--system/apache-cassandra/rc.cassandra95
1 files changed, 65 insertions, 30 deletions
diff --git a/system/apache-cassandra/rc.cassandra b/system/apache-cassandra/rc.cassandra
index 97a8e8f172..8fa5d9a7ce 100644
--- a/system/apache-cassandra/rc.cassandra
+++ b/system/apache-cassandra/rc.cassandra
@@ -1,41 +1,76 @@
#!/bin/bash
-set -e
+export JAVA="/usr/lib64/java/bin/java"
+export CASSANDRA_HOME="/opt/apache-cassandra"
+export CASSANDRA_CONF="$CASSANDRA_HOME/conf"
+export CASSANDRA_INCLUDE="$CASSANDRA_HOME/tools/bin/cassandra.in.sh"
-CASSANDRA_BIN_PATH="/opt/apache-cassandra/bin"
-PID_FILE="/var/run/cassandra.pid"
+PRG="cassandra"
+DIR="/opt/apache-cassandra/bin/"
+PID_DIRECTORY="/var/run"
+PID_FILE="$PID_DIRECTORY/$PRG.pid"
-stop_cassandra(){
- kill `cat $PID_FILE`
- rm -f $PID_FILE
+function isRunning() {
+[[ ! -f "$PID_FILE" ]] && return 1
+PID="$(<"$PID_FILE")"
+[[ -z "$PID" ]] && return 1
+[[ ! $(ps -p $PID | grep $PID) == "" ]] && RV=0 || RV=1
+return $RV
}
-if [ ! -d $CASSANDRA_BIN_PATH ]; then
- echo
- echo "Cassandra is not installed on this machine!"
- echo "Please check cassandra installation or set var CASSANDRA_BIN_PATH properly"
- echo
- exit 1
+function status() {
+isRunning
+STATUS=$?
+if [[ $STATUS -eq 0 ]]; then
+ echo -e "Service $PRG is running"
+else
+ echo -e "Service $PRG is not running."
fi
+}
+
+function start() {
+isRunning
+STATUS=$?
+if [[ $STATUS -eq 0 ]]; then
+ echo -e "Service $PRG is already running."
+else
+ echo -e "Start service $PRG"
+ $DIR$PRG -p $PID_FILE > /dev/null 2>&1 &
+fi
+}
+
+function stop() {
+isRunning
+STATUS=$?
+if [[ $STATUS -eq 0 ]]; then
+ echo -e "Stop service $PRG"
+ PID="$(<"$PID_FILE")"
+ kill $PID
+ rm "$PID_FILE"
+else
+ echo -e "Service $PRG not running."
+fi
+}
case $1 in
- start)
- echo " * Starting Cassandra..."
- $CASSANDRA_BIN_PATH/cassandra -p $PID_FILE > /dev/null 2>&1
- ;;
- stop)
- echo " * Stopping Cassandra..."
- stop_cassandra
- ;;
- restart)
- echo " * Rerstarting Cassandra..."
- stop_cassandra
- sleep 3
- $CASSANDRA_BIN_PATH/cassandra -p $PID_FILE > /dev/null 2>&1
- ;;
- *)
- echo " * Please provide correct option between start|stop|restart"
- ;;
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ start
+ sleep 1
+ stop
+ ;;
+ status)
+ status
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+ ;;
esac
-
+exit 0