#!/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"
FB_UDF="/Library/Frameworks/Firebird.framework/Resources/English.lproj/var/UDF"

if test -f "$FB_FW/Versions/A/Resources/English.lproj/var/security3.fdb"; then
	mv -f "$FB_FW/Versions/A/Resources/English.lproj/var/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/English.lproj/var/databases.conf"; then
	mv -f "$FB_FW/Versions/A/Resources/English.lproj/var/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/StartupItems/Firebird/Firebird ]; then
	/Library/StartupItems/Firebird/Firebird stop
	rm -fr /Library/StartupItems/Firebird
fi

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
