#!/bin/sh
#
# Script args:
# $0: full path to script
# $1: full path to top level package dir, no trailing slash
# $2: full path to installed location
# $3:  ????? Path to install Volume????
# $4:  ?????

FB_FW="/Library/Frameworks/Firebird.framework"
FB2_UDF="/Library/Frameworks/Firebird.framework/Resources/English.lproj/var/UDF"
FB3_UDF="/Library/Frameworks/Firebird.framework/Resources/UDF"

if test -f "$FB_FW/Versions/A/Resources/English.lproj/var/security2.fdb"; then
	mv -f "$FB_FW/Versions/A/Resources/English.lproj/var/security2.fdb" /tmp/fb-security-database-update2.fdb
fi

if test -f "$FB_FW/Versions/A/Resources/security3.fdb"; then
	mv -f "$FB_FW/Versions/A/Resources/security3.fdb" /tmp/fb-security-database-update3.fdb
fi

if test -f "$FB_FW/Versions/A/Resources/English.lproj/var/aliases.conf"; then
	mv -f "$FB_FW/Versions/A/Resources/English.lproj/var/aliases.conf" /tmp/fb-aliases.conf
fi

if test -f "$FB_FW/Versions/A/Resources/databases.conf"; then
	mv -f "$FB_FW/Versions/A/Resources/databases.conf" /tmp/fb-databases.conf
fi

rm $FB_UDF/fbudf*
rm $FB_UDF/ib_udf*
mkdir /tmp/UDF_save
cp $FB_UDF/*.* /tmp/UDF_save

if [ -f /Library/LaunchDaemons/org.firebird.gds.plist ]; then
	launchctl unload /Library/LaunchDaemons/org.firebird.gds.plist
	rm /Library/LaunchDaemons/org.firebird.gds.plist
fi

rm -fr "$FB_FW"
rm -fr /tmp/firebird

exit 0
