#!/bin/sh
#
# otopi -- plugable installer
#

script="$0"
scriptdir="$(dirname "${script}")"

pyscript_name=$(basename $0).py

# in source tree execution
if [ -f "${scriptdir}/.source" ]; then
	. ${scriptdir}/../../build/otopi-functions
	pyscript_path=${scriptdir}/${pyscript_name}
else
	# TODO here and elsewhere, take location of otopi-functions
	# from autotools instead of hard-coding
	. /usr/share/otopi/otopi-functions
	pyscript_path=/usr/share/otopi/scripts/${pyscript_name}
fi

OTOPI_PYTHON="${OTOPI_PYTHON:-$(get_otopi_python)}"

[ -z "${OTOPI_PYTHON}" ] && die "Python is required but missing"

exec "${OTOPI_PYTHON}" "${pyscript_path}" "$@"
