#! /bin/bash
## post-install <domain_home> <package_home>

domain_home=$1
package_home=$2

# set up vars
package_name=${package_home##*/}
profile_dir=${package_home}/etc/profile.d
profile_path=${profile_dir}/${package_name}.sh

# remove old script, if any
rm -f ${profile_path}

# create scripts .sh
mkdir -p ${profile_dir}

cat > "${profile_path}" <<EOF
if [[ -n "\${VGRIDDESCRIPTORS_VERSION}" && "\${VGRIDDESCRIPTORS_VERSION}" != $(echo ${package_name} | cut -d_ -f2 | cut -d\- -f1) ]];then
   echo "You already have a version of vgrid loaded, using two versions at the same time may cause problems"
fi
export VGRIDDESCRIPTORS_VERSION_COMP=$(echo ${package_name} | cut -d_ -f2)
export VGRIDDESCRIPTORS_VERSION=$(echo ${package_name} | cut -d_ -f2 | cut -d\- -f1)
export VGRIDDESCRIPTORS_SRC=${package_home}/src
EOF

