#!/usr/bin/env bash

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Detect # of CPUs so make jobs can be parallelized
CPUS=$(grep -c ^processor /proc/cpuinfo)
 # Available variables
# $BOSH_COMPILE_TARGET - where this package & spec'd source files are available
# $BOSH_INSTALL_TARGET - where you copy/install files to be included in package
export HOME=/var/vcap

#
# NOTE: new versions of redis can be found on the official
#       download page: http://redis.io/download
#

# from http://download.redis.io/releases/redis-3.2.3.tar.gz
echo "Extracting redis server ..."
tar xzf redis/redis-3.2.3.tar.gz

echo "Building redis ..."
pushd redis-3.2.3
  make install PREFIX=${BOSH_INSTALL_TARGET}
popd
