#!/bin/bash
#
# This postflight script echoes the values of the available 
# arguments and environmental variables.
# com.Plogue Art et Technologie, Inc.chipsounds
echo "Start postflight script"

defaults write "/Library/Preferences/com.Plogue Art et Technologie, Inc.chipsounds" base_dir "$2/Plogue chipsounds"
defaults write "/Library/Preferences/com.Plogue Art et Technologie, Inc.chipsounds" sample_dir "$2/Plogue chipsounds/Data"
defaults write "/Library/Preferences/com.Plogue Art et Technologie, Inc.chipsounds" version 1501

#Add then Set in case value already exists Add will fail.
"$1/Contents/Resources/PlistBuddy" -c "Add Products:1009 dict" /Library/Preferences/com.plogue.aria.plist
"$1/Contents/Resources/PlistBuddy" -c "Add Products:1009:vendor string Plogue Art et Technologie, Inc" /Library/Preferences/com.plogue.aria.plist
"$1/Contents/Resources/PlistBuddy" -c "Set Products:1009:vendor Plogue Art et Technologie, Inc" /Library/Preferences/com.plogue.aria.plist
"$1/Contents/Resources/PlistBuddy" -c "Add Products:1009:product string chipsounds" /Library/Preferences/com.plogue.aria.plist
"$1/Contents/Resources/PlistBuddy" -c "Set Products:1009:product chipsounds" /Library/Preferences/com.plogue.aria.plist

su $USER -c "\"$1/Contents/Resources/PlistBuddy\" -c \"Add Products:1009 dict\" ~/Library/Preferences/com.plogue.aria.plist"
su $USER -c "\"$1/Contents/Resources/PlistBuddy\" -c \"Add Products:1009:vendor string 'Plogue Art et Technologie, Inc'\" ~/Library/Preferences/com.plogue.aria.plist"
su $USER -c "\"$1/Contents/Resources/PlistBuddy\" -c \"Set Products:1009:vendor 'Plogue Art et Technologie, Inc'\" ~/Library/Preferences/com.plogue.aria.plist"
su $USER -c "\"$1/Contents/Resources/PlistBuddy\" -c \"Add Products:1009:product string chipsounds\" ~/Library/Preferences/com.plogue.aria.plist"
su $USER -c "\"$1/Contents/Resources/PlistBuddy\" -c \"Set Products:1009:product chipsounds\" ~/Library/Preferences/com.plogue.aria.plist"

#ln -s "/Library/Application Support/Plogue/Aria/AriaReporter.app" "$2/Plogue chipsounds/Report Technical Issue"

echo "End postflight script"
exit 0
