mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 16:56:15 +10:00
[#123] added additional checks and alternate download link for hbase
This commit is contained in:
+65
-20
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
HBASE_VERSION=hbase-0.94.24
|
||||
HBASE_VERSION=hbase-0.94.25
|
||||
HBASE_FILE=$HBASE_VERSION.tar.gz
|
||||
HBASE_DL_URL=http://apache.mirror.cdnetworks.com/hbase/$HBASE_VERSION/$HBASE_FILE
|
||||
HBASE_ARCHIVE_DL_URL=http://archive.apache.org/dist/hbase/$HBASE_VERSION/$HBASE_FILE
|
||||
|
||||
this="${BASH_SOURCE-$0}"
|
||||
while [ -h "$this" ]; do
|
||||
@@ -21,30 +22,74 @@ script=`basename "$this"`
|
||||
bin=`cd "$bin">/dev/null; pwd`
|
||||
this="$bin/$script"
|
||||
|
||||
CURRENT_DIR=$bin
|
||||
BASE_DIR=`dirname "$bin"`
|
||||
|
||||
CONF_DIR=$BASE_DIR/conf
|
||||
HBASE_DIR=$BASE_DIR/hbase
|
||||
|
||||
# check if HBase exists
|
||||
if [ -d $HBASE_DIR/$HBASE_VERSION ]; then
|
||||
echo "HBase already installed. Starting hbase..."
|
||||
function func_check_hbase_installation
|
||||
{
|
||||
if [ -d $HBASE_DIR/$HBASE_VERSION ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
function func_download_hbase
|
||||
{
|
||||
if type curl > /dev/null 2>&1; then
|
||||
if [[ `curl -s --head $HBASE_DL_URL | head -n 1 2>&1 | grep "HTTP/1.[01] [23].."` ]]; then
|
||||
curl -O $HBASE_DL_URL
|
||||
else
|
||||
curl -O $HBASE_ARCHIVE_DL_URL
|
||||
fi
|
||||
echo "true"
|
||||
elif type wget > /dev/null 2>&1; then
|
||||
if [[ `wget -S --spider $FAIL_URL 2>&1 | grep "HTTP/1.[01] [23].."` ]]; then
|
||||
wget $HBASE_DL_URL
|
||||
else
|
||||
wget $HBASE_ARCHIVE_DL_URL
|
||||
fi
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
function func_install_hbase
|
||||
{
|
||||
if [ ! -d $HBASE_DIR ]; then
|
||||
mkdir $HBASE_DIR
|
||||
fi
|
||||
cd $HBASE_DIR
|
||||
echo "Downloading hbase..."
|
||||
download_successful=$(func_download_hbase)
|
||||
if [[ "$download_successful" == "false" ]]; then
|
||||
echo "hbase download failed - wget or curl required."
|
||||
echo "Exiting"
|
||||
exit 0
|
||||
fi
|
||||
tar xzf $HBASE_FILE
|
||||
rm $HBASE_FILE
|
||||
ln -s $HBASE_VERSION hbase
|
||||
cp $CONF_DIR/hbase/hbase-site.xml $HBASE_DIR/$HBASE_VERSION/conf/
|
||||
chmod +x $HBASE_DIR/$HBASE_VERSION/bin/start-hbase.sh
|
||||
}
|
||||
|
||||
function func_start_hbase
|
||||
{
|
||||
hbase_already_installed=$(func_check_hbase_installation)
|
||||
if [[ "$hbase_already_installed" == "true" ]]; then
|
||||
echo "HBase already installed. Starting hbase..."
|
||||
else
|
||||
echo "Hbase not detected."
|
||||
func_install_hbase
|
||||
fi
|
||||
cd $HBASE_DIR/$HBASE_VERSION/bin
|
||||
./start-hbase.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# install and start HBase standalone
|
||||
echo "HBase not detected. Installing hbase..."
|
||||
mkdir $HBASE_DIR
|
||||
cd $HBASE_DIR
|
||||
wget $HBASE_DL_URL 2>/dev/null || curl -O $HBASE_DL_URL
|
||||
tar xzf $HBASE_FILE
|
||||
rm $HBASE_FILE
|
||||
cp $CONF_DIR/hbase/hbase-site.xml $HBASE_DIR/$HBASE_VERSION/conf/
|
||||
cd $HBASE_DIR/$HBASE_VERSION/bin
|
||||
|
||||
echo "HBase installation complete. Starting hbase..."
|
||||
chmod +x start-hbase.sh
|
||||
./start-hbase.sh
|
||||
cd $CURRENT_DIR
|
||||
}
|
||||
|
||||
func_start_hbase
|
||||
Reference in New Issue
Block a user