#!/usr/bin/env bash # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. # # Install Apache Cassandra. # set -x set -e C_VERSION=${1:-0.6.2} CASSANDRA_HOME=/usr/local/apache-cassandra-$C_VERSION C_CONF_DIR=/etc/cassandra/conf C_LOG_DIR=/var/log/cassandra c_tar_url=http://www.apache.org/dist/cassandra/$C_VERSION/apache-cassandra-$C_VERSION-bin.tar.gz c_tar_file=`basename $c_tar_url` c_tar_md5_file=`basename $c_tar_url.md5` curl="curl --retry 3 --silent --show-error --fail" for i in `seq 1 3`; do $curl -O $c_tar_url $curl -O $c_tar_url.md5 if md5sum -c $c_tar_md5_file; then break; else rm -f $c_tar_file $c_tar_md5_file fi done if [ ! -e $c_tar_file ]; then echo "Failed to download $c_tar_url. Aborting." exit 1 fi tar zxf $c_tar_file -C /usr/local rm -f $c_tar_file $c_tar_md5_file echo "export CASSANDRA_HOME=$CASSANDRA_HOME" >> /etc/profile echo 'export PATH=$CASSANDRA_HOME/bin:$PATH' >> /etc/profile mkdir -p /mnt/cassandra/logs ln -s /mnt/cassandra/logs $C_LOG_DIR mkdir -p $C_CONF_DIR cp $CASSANDRA_HOME/conf/log4j.properties $C_CONF_DIR cp $CASSANDRA_HOME/conf/storage-conf.xml $C_CONF_DIR sed -i -e "s|CASSANDRA_CONF=\$cassandra_home/conf|CASSANDRA_CONF=$C_CONF_DIR|" $CASSANDRA_HOME/bin/cassandra.in.sh # Ensure Cassandra starts on boot cat > /etc/rc.local < /dev/null 2>&1 & EOF