#!/bin/sh

# BluetoothAutomation
BAM_SCRIPTING_PATH="/AppleInternal/Library/Frameworks/BluetoothAutomation.framework/Resources/Scripting"

# Python
PYTHON_INSTALL_PATH=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`

# Code below runs as root during installation - check proper values
if [ x"$PYTHON_INSTALL_PATH" != "x" -a y"$BAM_SCRIPTING_PATH" != "y" ]; then
	sudo rm -rf "${PYTHON_INSTALL_PATH}/bluetoothautomation";
	sudo rm -rf "${PYTHON_INSTALL_PATH}/bluetoothautomationservice";

	sudo ln -sf "${BAM_SCRIPTING_PATH}/python_libraries/bluetoothautomation" "${PYTHON_INSTALL_PATH}/bluetoothautomation";
	sudo ln -sf "${BAM_SCRIPTING_PATH}/python_libraries/bluetoothautomationservice" "${PYTHON_INSTALL_PATH}/bluetoothautomationservice";

	echo "Python libraries installed at ${PYTHON_INSTALL_PATH}"
else
	echo "Error determining Python install path or Bluetooth Automation install path."
	exit 1
fi
exit 0
