#!/bin/bash
#

# For old installs, need to remove user local copies of some files
# Enounce, Inc, copyright (c) 2010. All rights reserved.
#
# remove the Enounce AUTimePitch Audio Unit
if [ -e /Library/Audio/Plug-Ins/Components/AUTimePitch.component ] 
then 
    echo "Removing AUTimePitch"
    rm -rf /Library/Audio/Plug-Ins/Components/AUTimePitch.component 
fi

# Remove the NPAPI MySpeed Plugin, if it exists
if [ -e /Library/Internet\ Plug-Ins/NPMySpeedPlugin.plugin ] 
then 
    echo "Removing NPMySpeedPlugin"
    rm -rf /Library/Internet\ Plug-Ins/NPMySpeedPlugin.plugin 
fi

# Remove the MySpeed Scripting Addition, if it exists
if [ -e /Library/ScriptingAdditions/MySpeed.osax ] 
then 
    echo "Removing MySpeed.osax"
    rm -rf /Library/ScriptingAdditions/MySpeed.osax 
fi

# Remove MySpeed, if it exists
if [ -e /Applications/MySpeed.app ] 
then 
    echo "Removing MySpeed"
    rm -rf /Applications/MySpeed.app
fi

# Restore Safari Sandbox, if necessary
pathToSafariPrivateSandbox=/System/Library/PrivateFrameworks/WebKit2.framework/WebProcess.app/Contents/Resources/com.apple.WebProcess.sb
pathToSafariPrivateSandboxBackup=/System/Library/PrivateFrameworks/WebKit2.framework/WebProcess.app/Contents/Resources/com.apple.WebProcess.sb.Original
pathToSafariStagedSandbox=/System/Library/StagedFrameworks/Safari/WebKit2.framework/WebProcess.app/Contents/Resources/com.apple.WebProcess.sb
pathToSafariStagedSandboxBackup=/System/Library/StagedFrameworks/Safari/WebKit2.framework/WebProcess.app/Contents/Resources/com.apple.WebProcess.sb.Original

pathToMySpeedSandbox=/Library/Sandbox/Profiles/com.enounce.MySpeed.sb
if [ -e "$pathToSafariPrivateSandboxBackup" ]
then
    echo "Restoring Private Safari Sandox"
    mv -f $pathToSafariPrivateSandboxBackup $pathToSafariPrivateSandbox
fi

if [ -e "$pathToSafariStagedSandboxBackup" ]
then
    echo "Restoring Staged Safari Sandox"
    mv -f $pathToSafariStagedSandboxBackup $pathToSafariStagedSandbox
fi

# Remove MySpeed sandbox, if it exists
if [ -e "$pathToMySpeedSandbox" ]
then
    echo "Removing MySpeed Sandbox"
    rm -rf $pathToMySpeedSandbox
fi


