#!/bin/bash
set -e

build_dir="$(mktemp -d)"

echo "Extracting nginx..."
tar xzvf nginx/nginx-*.tar.gz --strip-components=1 -C "$build_dir"

if [[ $? != 0 ]] ; then
  echo "Failed extracting nginx"
  exit 1
fi

echo "Building nginx..."
pushd "$build_dir"
  ./configure \
    --prefix=${BOSH_INSTALL_TARGET} \
    --with-http_ssl_module \
    --without-http_rewrite_module

  make
  make install
popd
