#!/bin/bash

set -e

APP_DIR="/usr/share/pepper"
VENV_DIR="${APP_DIR}/venv"

if [[ ! -d "${APP_DIR}" ]]; then
    echo "Error: PEpper installation directory not found:"
    echo "${APP_DIR}"
    exit 1
fi

if [[ -x "${VENV_DIR}/bin/python" ]]; then
    PYTHON="${VENV_DIR}/bin/python"
else
    PYTHON="/usr/bin/python3"
fi

exec "${PYTHON}" "${APP_DIR}/pepper.py" "$@"
