#!/bin/bash
#
# This postflight script echoes the values of the available 
# arguments and environmental variables.
#
echo "Start postflight script"
echo ""
echo "Arguments:"
echo ""
echo "\$1: full path to the installation package"
echo "     $1"
echo "\$2: full path to the installation destination"
echo "     $2"
echo "\$3: mountpoint of the destination volume"
echo "     $3"
echo "\$4: root directory \"/\" for the current System folder"
echo "     $4"
echo ""
echo "Environment variables available to a postflight executable:"
echo "     INSTALLER_TEMP, PACKAGE_PATH, RECEIPT_PATH, SCRIPT_NAME, and TMPDIR"
echo ""
echo "\$INSTALLER_TEMP: scratch area used by Installer for temporary work files"
echo "     $INSTALLER_TEMP"
echo ""
echo "\$PACKAGE_PATH: full path to the installation package; should be same as \$1"
echo "     $PACKAGE_PATH"
echo ""
echo "\$RECEIPT_PATH: full path to directory containing the file being executed"
echo "     $RECEIPT_PATH"
echo ""
echo "\$SCRIPT_NAME: name of the file being executed"
echo "     $SCRIPT_NAME"
echo ""
echo "\$TMPDIR: if set, a path to a location on a writable destination volume"
echo "     $TMPDIR"
echo ""
echo "End postflight script"
ln -s  "$2/DVD to iPod Converter.app" "$HOME/desktop/DVD to iPod Converter"

chmod  -R 777 "$2" 
echo "ProductVars=$1">>"$2/DVD to iPod Converter.app"/Contents/Resources/config.ini

mpkg=${1%%/Contents/*.pkg}
echo "[Package]">>"$2/DVD to iPod Converter.app"/Contents/Resources/config.ini
echo "PackageVars=$mpkg">>"$2/DVD to iPod Converter.app"/Contents/Resources/config.ini
#<package>
CURRENT_ARCH=`arch`
echo "[ARCH]">>"$2/DVD to iPod Converter.app"/Contents/Resources/config.ini
echo "RunArch=$CURRENT_ARCH">>"$2/DVD to iPod Converter.app"/Contents/Resources/config.ini

exit 0

