blob: cb1ec107ea19da325cd9eb4886b486dc8a90e427 [file] [log] [blame]
#!/bin/bash
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# This can be run or sourced, which is why we don't choose to exec the final
# launch line.
FINGER_COUNT=2
ENROLLMENT_COUNT=20
VERIFICATION_COUNT=15
PICTURE_DIR=./fpstudy-fingers
# If LOG_DIR is left empty, log to console
LOG_DIR=
FPSTUDY_VIRTENV=/tmp/virtualenv-study
# Check for required commands.
CMDS_REQUIRED=( pip3 virtualenv )
if ! which "${CMDS_REQUIRED[@]}" >/dev/null 2>&1; then
echo "Error - Missing one or more required commands: ${CMDS_REQUIRED[*]}" >&2
exit 1
fi
# Find the fingerprint study base directory.
study_dir="$(dirname "${BASH_SOURCE[0]}")"
# Setup New Virtualenv
rm -rf "${FPSTUDY_VIRTENV}"
if ! virtualenv -p python3 "${FPSTUDY_VIRTENV}"; then
echo "Error - Failed to setup a python virtualenv." >&2
exit 1
fi
# shellcheck source=/dev/null
. "${FPSTUDY_VIRTENV}/bin/activate"
if ! pip3 install -r "${study_dir}/requirements.txt"; then
echo "Error - Failed to install python dependencies." >&2
exit 1
fi
if [[ -n "${LOG_DIR}" ]]; then
mkdir -p "${LOG_DIR}"
fi
PATH="${study_dir}/mock-bin:${PATH}" "${study_dir}/study_serve.py" \
--finger_count="${FINGER_COUNT}" \
--enrollment_count="${ENROLLMENT_COUNT}" \
--verification_count="${VERIFICATION_COUNT}" \
--picture_dir="${PICTURE_DIR}" \
--log_dir="${LOG_DIR}" \
"$@"