#!/bin/bash
DRIVER_NAME="konalhi"

RTENABLER="Library/Application Support/Final Cut Pro System Support/Plugins"
FCP_USER_DATA="Library/Preferences/Final Cut Pro User Data/"
CUSTOM_SETTINGS="Library/Application Support/Final Cut Pro System Support/Custom Settings"
PREFPANE="Library/PreferencePanes"
STARTUP_ITEMS="Library/StartupItems"

# Remove any obsolete installs
"$3/bin/rm" -rf $3/System/Library/Extensions/*KHD.kext
"$3/bin/rm" -rf $3/System/Library/Extensions/*KSD.kext
"$3/bin/rm" -rf $3/System/Library/Extensions/*KONAOEM.kext
"$3/bin/rm" -rf $3/System/Library/Extensions/*KONA3OEM.kext
"$3/bin/rm" -rf $3/System/Library/Extensions/*KONALHOEM.kext
"$3/bin/rm" -rf $3/System/Library/Extensions/AJAOEM*.kext

"$3/bin/rm" -rf $3/Library/StartupItems/avksd
"$3/bin/rm" -rf $3/Library/StartupItems/avkhd
"$3/bin/rm" -rf $3/Library/StartupItems/AJAKonaStartupD
"$3/bin/rm" -rf $3/Library/Application\ Support/AJA/AJADaemon
"$3/bin/rm" -rf $3/Library/Application\ Support/AJA/AJAAgent

"$3/bin/rm" -rf $3/Applications/Kona\ Utilities/AJA*
"$3/bin/rm" -f $3/Applications/Kona\ Utilities
"$3/bin/rm" -rf $3/Applications/AJA\ Kona\ Utilities/AJA*
"$3/bin/rm" -f $3/Applications/AJA\ Kona\ Utilities
"$3/bin/rm" -rf $3/Applications/KHDWatcher.app
"$3/bin/rm" -rf $3/Applications/KSDWatcher.app
"$3/bin/rm" -rf $3/Applications/Kona*

"$3/bin/rm" -rf $3/Library/Receipts/Kona2.pkg
"$3/bin/rm" -rf $3/Library/Receipts/AJA\ KONA*
"$3/bin/rm" -rf $3/Library/Receipts/AJA\ OEM*
"$3/bin/rm" -rf $3/Library/Receipts/AJA\ IoHD*

# Remove common install items
"$3/bin/rm" -rf $3/Library/LaunchDaemons/com.aja*.plist
"$3/bin/rm" -rf $3/usr/libexec/ajad

"$3/bin/rm" -rf $3/Library/QuickTime/Kona*.component
"$3/bin/rm" -rf $3/Library/QuickTime/AJA*.component

"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ Conflict\ Checker.app
"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ DataCalc.app
"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ DPXToQTTranslator.app
"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ QTToDPXTranslator.app
"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ System\ Test.app
"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ TV.app
"$3/bin/rm" -rf $3/Applications/AJA\ Utilities/AJA\ Uninstaller.app

"$3/bin/rm" -rf $3/Applications/AJA\ ControlPanel.app

"$3/bin/rm" -rf $3/Users/*/Library/Preferences/com.aja.application.k?dcontrolpanel.plist
"$3/bin/rm" -rf $3/Library/Preference/com.aja.Kona*.plist

if [ "$DRIVER_NAME" == "kona3" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJAKONA3.kext
	"$3/bin/rm" -rf $3/Library/Receipts/Kona3.pkg
fi

if [ "$DRIVER_NAME" == "konalhi" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJAKONALHi.kext
	"$3/bin/rm" -rf $3/Library/Receipts/KonaLHI.pkg
fi

if [ "$DRIVER_NAME" == "konalh" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJAKONALH.kext
	"$3/bin/rm" -rf $3/Library/Receipts/KonaLH.pkg
fi

if [ "$DRIVER_NAME" == "konals" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJAKONALS.kext
	"$3/bin/rm" -rf $3/Library/Receipts/KonaLS.pkg
fi

if [ "$DRIVER_NAME" == "iohd" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJAIoHD.kext
	"$3/bin/rm" -rf $3/Library/Receipts/IoHD.pkg
fi

if [ "$DRIVER_NAME" == "ioexpress" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJAIoExpress.kext
	"$3/bin/rm" -rf $3/Library/Receipts/IoExpress.pkg
fi

if [ "$DRIVER_NAME" == "corvid" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJACorvid.kext
	"$3/bin/rm" -rf $3/Library/Receipts/Corvid.pkg
fi

if [ "$DRIVER_NAME" == "corvid22" ]; then
	"$3/bin/rm" -rf $3/System/Library/Extensions/AJACorvid22.kext
	"$3/bin/rm" -rf $3/Library/Receipts/Corvid22.pkg
fi