#!/bin/bash
# Preinstall script for HOBOware installer
#
# Note - Executable property has been set in Subversion
#
echo "" >> ~/HOBOwareInstall.txt
echo "preinstall script" >> ~/HOBOwareInstall.txt
echo "" >> ~/HOBOwareInstall.txt
echo "Path to installer: $1" >> ~/HOBOwareInstall.txt
echo "Path to install destination: $2" >> ~/HOBOwareInstall.txt
echo "Root of destination volume: $3" >> ~/HOBOwareInstall.txt
echo "Root of System: $4" >> ~/HOBOwareInstall.txt
echo "Scratchpad area used by installer at $INSTALLER_TEMP" >> ~/HOBOwareInstall.txt

# 02SEP2009 jed, OS X 10.6 (Snow Leopard) seems to only send 3 parameters. For now, I'm
#                assuming the fourth parameter is the root of the System and it is
#                being forced to be "/" for now.
if (( $# != 4 ))
then
	echo "Only $# arguments received from Install.app. Adding System root argument." >> ~/HOBOwareInstall.txt
	echo "" >> ~/HOBOwareInstall.txt
	source "${1%/}/Contents/Resources/OnsetPreFunctions" "$@" "/" "$INSTALLER_TEMP"
else
	echo "All 4 arguments received from Installer.app." >> ~/HOBOwareInstall.txt
	echo "" >> ~/HOBOwareInstall.txt
	source "${1%/}/Contents/Resources/OnsetPreFunctions" "$@" "$INSTALLER_TEMP"
fi

exit $?
