diff --git a/dev-support/deploy.sh b/dev-support/deploy.sh new file mode 100755 index 0000000..81d0cd2 --- /dev/null +++ b/dev-support/deploy.sh @@ -0,0 +1,172 @@ +#!/bin/bash +# Build and deploy a standalone instance of hbase from source +#directory to deploy hbase from +DEPLOY="deploy" +#data directory under the deploy directory, from which to deploy +DATA="data" +#configuration that should be used +CONF= + +usage() +{ +cat << EOF +usage: $0 [options] + +Build, package and deploy local hbase from the current directory. +It deploys the built hbase from the child directory in local mode. +This script also attempts to shutdown the existing instance, if it is already started. + +options: + -h Show this message + -d DIR Set the deployment directory. Defaults to '${DEPLOY}' + -s DIR Set the data storage directory on the local file system, relative to the deployment directory. Defaults to '${DATA}'. + -x Expedite process by skipping building of the tarball. Assumes there is a tarball in the hbase/target directory. + -c Clean deploy hbase; removes the previous deploy directory (with the same name as here), if it exists + -p FILE Absolute path to a file with extra configuration settings, which are appended to the default hbase-site.xml. +EOF +} + +#Parse out all the options +while getopts "chxs:d:p:" OPTION +do + case $OPTION in + h) + usage + exit 0 + ;; + s) + DATA=$OPTARG + ;; + d) + DEPLOY=$OPTARG + ;; + x) + BUILD=1 + ;; + c) + CLEAN=1 + ;; + p) + CONF=$OPTARG + ;; + \?) + usage + exit 1 + esac +done + +set -e + +#pull the version from maven +VERSION=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | egrep "^[^[]"` +echo "Version = ${VERSION}" +if [ ! $VERSION ]; then + echo "No hbase version could be found!" + exit 1 +fi + +#set the build directory from the version +directory=hbase-${VERSION} + + +#################### +# Build the tarball +#################### + +BUILD_LINE="mvn clean package assembly:assembly -DskipTests" + +#Skip building if that is disabled +if [ ! $BUILD ]; then + echo "Staring compilation..." + $BUILD_LINE +fi + + +################ +# Deployment +############### + +# make sure the deploy directory exists +if [ ! -d $DEPLOY ]; then + echo "Deploy directory doesn't exist, creating..." + mkdir $DEPLOY +fi + +#now attempt to stop the previous version +#ignore errors stopping hbase +set +e +home=${DEPLOY}/${directory} +echo "Home is: ${home}" +if [ -d "$home" ]; then + echo "Attempting to stop existing hbase instance..." + ./$home/bin/stop-hbase.sh +fi + +# start failing on errors again +set -e + +#then clean the existing directory +if [ $CLEAN ]; then + echo "Cleaning deploy directory (${DEPLOY})..." + rm -rf ${DEPLOY}/* +fi + +echo "Copying over the built tarball" + +tarball=${directory}.tar.gz +full_tarball=${DEPLOY}/${tarball} +# remove the previous tarball, if one exists +if [ -e ${ful_tarball} ]; then + rm ${full_tarball} +fi +cp target/${tarball} ${full_tarball} + +# go into the deployment directory +cd ${DEPLOY} + +echo "Untaring ${tarball} into ${DEPLOY}..." +tar xf ${tarball} +echo "Done untaring!" + +########################## +# Update the configuration +########################## + +#then go into the exploded directory +cd ${directory} +if [ ! -d "${DATA}" ];then + mkdir $DATA +fi + +# update the hbase-site.xml for the data directory +echo " + + + + hbase.rootdir + file://`pwd`/$DATA + " > conf/hbase-site.xml + +# if we have a configuration specified, append it to the current configuration +if [ ${CONF} ]; then + #Just copy over the hbase site conf provided into the configuration directory + cat ${CONF} >>conf/hbase-site.xml +fi + +echo " +" >>conf/hbase-site.xml + +echo "Updated hbase-site for local data directory." +HBASE_CLASSPATH=`pwd`/lib + + +############## +# Start HBase +############## + +#now start the new hbase instance +set -e +echo "Starting hbase..." +./bin/start-hbase.sh + +exit 0