#!/bin/bash
# now using uv, unbelieveably simpler.
# Run this in a terminal in ~/expo above the troggle directory: 'bash ~/expo/venv-trog.sh'
echo '-- Run this in a terminal in the directory above the troggle directory: "bash ~/expo/venv-trog.sh"'

# Expects an Ubuntu 24.04 with all the gubbins already installed
# If you have not already installed these on your clean Ubuntu install DO THIS FIRST
# use the script os-trog24.04.sh runniing it in /home/username/
python3 --version
cd ~/expo/troggle
echo "-- EXPO    folder [current directory]:    `pwd`"
TROGDIR=$(cd $(dirname $0) && pwd)
echo "-- Troggle folder: ${TROGDIR}"

cp dev.toml pyproject.toml
cp ~/expo/troggle/_deploy/wsl/localsettingsWSL.py ~/expo/troggle/localsettings.py

uv self update
uv sync


# fudge for philip's laptop prior to M2 SSD upgrade
if [ ! -d /mnt/d/EXPO ]; then
  sudo mkdir /mnt/d
  sudo mount -t drvfs D: /mnt/d
fi
  
uv pip list

echo "Django version:`uv run django-admin --version`"

echo "### Now do 
  '[sudo service mysql start]'
  '[sudo service mariadb restart]'
  '[sudo mysql_secure_installation]'
  'cd ~/expo/troggle'
  'uv run django-admin'
  'uv run manage.py check'
## this tests if you have set up ssh correcting. Refer to documentation https://expo.survex.com/handbook/computing/keyexchange.html
## you need to follow the Linux instructions.
  'ssh expo@expo.survex.com'

## the next tests will fail unless ~/expofiles is set correctly to a folder on your machine

   'uv run  manage.py test -v 2'
   './pre-run.sh' (runs the tests again)
   
   'uv run  databaseReset.py reset INIT'
   'uv run  manage.py runserver 0.0.0.0:8000 (and allow access when the firewall window pops up)'
   "
# if [ ! -d /mnt/d/expofiles ]; then
  # echo '### No valid expofiles directory on /mnt/d . Fix this before any tests will work.'
# fi