#!/bin/bash

# This script is a hook called via the dt-install-sandbox-software command.
# Do not run it directly.

[ -z "$1" ] && echo "Run dt-install-sandbox-software to call this script" && exit 1

if [ "$1" != "--env-loaded" ]; then
	[ -z "$2" ] && echo "Run dt-install-sandbox-software (version 1) to call this script" && exit 1
	[ -z "$CSBE_SANDBOX" ] && export CSBE_SANDBOX=$1      # root of the sandbox
	[ -z "$CSBE_TOP" ] && export CSBE_TOP=$2              # root of the primary git project
	[ -z "$CSBE_NAME" ] && export CSBE_NAME=`dirname $CSBE_SANDBOX`
	SB_ENV_FILE=$3                                        # name of the environment file to use
	[ -z "$SB_ENV_FILE" ] && SB_ENV_FILE=defaults.sh
	. $CSBE_TOP/sandbox/$SB_ENV_FILE
fi

# Install node if specified with CSBE_NODE_VER
[ -n "$CSBE_NODE_VER" -a ! -L $CSBE_SANDBOX/node ] && dt-get-software -V $CSBE_NODE_VER node $CSBE_SANDBOX


# Put custom one-time only software installations here (such as git clones of additional repos,
# other software packages that will live in the sandbox, etc...).
#
# Note that there is no sandbox process, other than a first time install, that exeutes this hook.

# $CS_API_TOP/sandbox/install-sandbox-software --env-loaded
# $CS_BROADCASTER_TOP/sandbox/install-sandbox-software --env-loaded
# $CS_MAILIN_TOP/sandbox/install-sandbox-software --env-loaded
# $CS_OUTBOUND_EMAIL_TOP/sandbox/install-sandbox-software --env-loaded

exit 0
