Skip to content

Instantly share code, notes, and snippets.

@joeljacobson
Last active July 15, 2018 17:50
Show Gist options
  • Save joeljacobson/b9c70f36c429e61992f0 to your computer and use it in GitHub Desktop.
Save joeljacobson/b9c70f36c429e61992f0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Maintainer Joel Jacobson
VERSION="5.0.0"
# to start the services you must be root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# check if java is installed
echo 'checking if java is installed'
if type -p java; then
echo 'found java executable in PATH'
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
echo 'found java executable in JAVA_HOME'
_java="$JAVA_HOME/bin/java"
else
echo "java is not installed"
exit 1
fi
# check if java 8 is installed
if [[ "$_java" ]]; then
version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
echo version "$version"
if [[ "$version" > "1.8" ]]; then
echo 'java 8 is installed, proceeding... '
else
echo 'java version is lower than 1.8, please upgrade to 1.8 or higher to proceed'
exit 1
fi
fi
# check if cassandra is present
if [ ! -f dse-$VERSION.tar.gz ] ; then
echo "Package not found, if you don't have it, you can't get it!"
exit 1
fi
# check if dse has been unpacked
if [ ! -d hadoop ] & [ ! -d hulk ] & [ ! -d tinkerpop ] & [ ! -d bdp ] & [ ! -d incubator-tinkerpop ] ; then
echo 'unpacking dse-5.0.0'
tar xvf dse-$VERSION.tar.gz
fi
# check if cassandra is running, if not start it
if ps aux | grep -v grep | grep cass &> /dev/null
then
echo '...cassandra is running...'
else
echo '...starting cassandra...'
bdp/bin/dse cassandra &> /dev/null
sleep 3
fi
# check if hulk is running, if not start it
if ps aux | grep -v grep | grep hulk &> /dev/null
then
echo '...hulk is running on http://127.0.0.1:9091...'
else
echo '...starting hulk...HULK IS TURNING GREEN!...'
cd hulk && nohup bin/hulk &> /dev/null &
echo '...Hulk SMASH on http://127.0.0.1:9091...'
fi
# start gremlin shell
echo '...starting gremlin shell...'
cd tinkerpop && bin/gremlin.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment