#!/bin/bash
# This script sets up a virtual environment for the Conjurer Librarian service and installs the required dependencies.


# Create a virtual environment at /home/pi/Conjurer_librarian/env
python3 -m venv /home/pi/Conjurer_librarian/env

# Copy the Conjurer Librarian Python script to the appropriate directory
cp /home/pi/conjurer/conjurer_librarian/conjurer_librarian.py ./Conjurer_librarian/

# Copy the requirements file to the appropriate directory
cp /home/pi/conjurer/conjurer_librarian/requirements_librarian.txt ./Conjurer_librarian/

# Change directory to /home/pi/Conjurer_librarian
cd /home/pi/Conjurer_librarian

touch /home/pi/Conjurer/rr_results.json
touch /home/pi/Conjurer/cr_results.json
touch /home/pi/Conjurer/s_results.json
touch /home/pi/Conjurer/rr_results.json
touch /home/pi/Conjurer/not_in_db.json

# Activate the virtual environment
source /home/pi/Conjurer_librarian/env/bin/activate

# Upgrade pip
./env/bin/python3 -m pip install --upgrade pip

# Install the required dependencies
./env/bin/python3 -m pip install -r requirements_librarian.txt

# Deactivate the virtual environment
deactivate
