2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-12-18 14:32:19 +00:00

minor comments

This commit is contained in:
Philip Sargent 2024-12-11 22:22:51 +00:00
parent 54a069df84
commit eb07a36eaf
2 changed files with 185 additions and 183 deletions

View File

@ -83,6 +83,8 @@ echo '###'
echo '### Now YOU have to configure the git settings for YOURSELF (not "expo")' echo '### Now YOU have to configure the git settings for YOURSELF (not "expo")'
echo '### because you can't clone the repos without a key echo '### because you can't clone the repos without a key
# This sets this up for bash command window, BUT it is is not enough for VS code which is actually a Windows app
# when running on WSL. You ALSO need to MANUALLY run these commands in a terminal windows INSIDE VS code
git config --global user.email "philip.sargent@gmail.com" git config --global user.email "philip.sargent@gmail.com"
git config --global user.name "Philip Sargent" git config --global user.name "Philip Sargent"
git config --global pull.rebase true git config --global pull.rebase true

366
_deploy/wsl/venv-trog-d4.sh Executable file → Normal file
View File

@ -1,184 +1,184 @@
#!/bin/bash #!/bin/bash
# footled lots to make this work with python 3.10 & 3.11 and WSL1 and WSL2 on Ubuntu 22.04 # footled lots to make this work with python 3.10 & 3.11 and WSL1 and WSL2 on Ubuntu 22.04
# Run this in a terminal in the troggle directory: 'bash venv-trog.sh' # Run this in a terminal in the troggle directory: 'bash venv-trog.sh'
echo '-- Run this in a terminal in the real troggle directory: "bash venv-trog.sh"' echo '-- Run this in a terminal in the real troggle directory: "bash venv-trog.sh"'
# Expects an Ubuntu 22.04 (or 20.04) relatively clean install. # Expects an Ubuntu 22.04 with all the gubbins pre-installed
# If you have not already installed these on your clean Ubuntu install DO THIS FIRST # If you have not already installed these on your clean Ubuntu install DO THIS FIRST
# use the script os-trog.sh # use the script os-trog.sh
# If you are using Debian, then stick with the default version of python # If you are using Debian, then stick with the default version of python
# If you are using Ubuntu, then it is easy to use a later version of python, e.g. 3.11 # If you are using Ubuntu, then it is easy to use a later version of python, e.g. 3.11
# NOW we set up troggle # NOW we set up troggle
PYTHON=python3.11 PYTHON=python3.11
VENAME=p11d42 # python3.x and django 4.2 VENAME=p11d42 # python3.x and django 4.2
echo "** You are logged in as `id -u -n`" echo "** You are logged in as `id -u -n`"
echo "The 50MB pip cache will be in /home/`id -u -n`/.cache/" echo "The 50MB pip cache will be in /home/`id -u -n`/.cache/"
echo "The 150MB venv will created in /home/`id -u -n`/$VENAME/" echo "The 150MB venv will created in /home/`id -u -n`/$VENAME/"
TROGDIR=$(cd $(dirname $0) && pwd) TROGDIR=$(cd $(dirname $0) && pwd)
echo "-- Troggle folder (this script location): ${TROGDIR}" echo "-- Troggle folder (this script location): ${TROGDIR}"
REQUIRE=requirements-$VENAME.txt REQUIRE=requirements-$VENAME.txt
if [ -d $REQUIRE ]; then if [ -d $REQUIRE ]; then
echo "-- No ${REQUIRE} found. You should be in the /troggle/ folder. Copy it from your most recent installation." echo "-- No ${REQUIRE} found. You should be in the /troggle/ folder. Copy it from your most recent installation."
exit 1 exit 1
fi fi
echo ## Using $REQUIRE : echo ## Using $REQUIRE :
cat $REQUIRE cat $REQUIRE
echo ## echo ##
$PYTHON --version $PYTHON --version
# NOTE that when using a later or earlier verison of python, you MUST also # NOTE that when using a later or earlier verison of python, you MUST also
# use the allowed version of Pillow, see https://pillow.readthedocs.io/en/latest/installation.html # use the allowed version of Pillow, see https://pillow.readthedocs.io/en/latest/installation.html
# NOW set up link from expo user folder # NOW set up link from expo user folder
# needed for WSL2 # needed for WSL2
echo Creating links from Linux filesystem user echo Creating links from Linux filesystem user
# These links only need making once, for many venv # These links only need making once, for many venv
cd ~ cd ~
if [ ! -d $VENAME ]; then if [ ! -d $VENAME ]; then
echo "## Creating venv $VENAME. (If this fails with a pip error, you need to ensure you have python3.11-venv installed and/or use a Ubuntu window)" echo "## Creating venv $VENAME. (If this fails with a pip error, you need to ensure you have python3.11-venv installed and/or use a Ubuntu window)"
$PYTHON -m venv $VENAME $PYTHON -m venv $VENAME
else else
echo "## /$VENAME/ already exists ! Delete it first." echo "## /$VENAME/ already exists ! Delete it first."
exit 1 exit 1
fi fi
# Activate the virtual env and see what the default packages are # Activate the virtual env and see what the default packages are
echo "### Activating $VENAME" echo "### Activating $VENAME"
cd $VENAME cd $VENAME
echo "-- now in: ${PWD}" echo "-- now in: ${PWD}"
ls -tlarg ls -tlarg
source bin/activate source bin/activate
echo $VIRTUAL_ENV echo $VIRTUAL_ENV
if [ -d ~/$VENAME/bin ]; then if [ -d ~/$VENAME/bin ]; then
echo "### Activating." echo "### Activating."
else else
echo "## ~/$VENAME/bin does not exist. FAILed to create venv properly." echo "## ~/$VENAME/bin does not exist. FAILed to create venv properly."
exit 1 exit 1
fi fi
# update local version of pip, more recent than OS version # update local version of pip, more recent than OS version
# debian bullseye installs pip 20.3.4 which barfs, we want >22.0.3 # debian bullseye installs pip 20.3.4 which barfs, we want >22.0.3
# update local version of setuptools, more recent than OS version, needed for packages without wheels # update local version of setuptools, more recent than OS version, needed for packages without wheels
echo "### installing later version of pip inside $VENAME" echo "### installing later version of pip inside $VENAME"
$PYTHON -m pip install --upgrade pip $PYTHON -m pip install --upgrade pip
$PYTHON -m pip install --upgrade setuptools $PYTHON -m pip install --upgrade setuptools
PIP=pip PIP=pip
$PIP list > original-pip.list $PIP list > original-pip.list
$PIP freeze >original.txt $PIP freeze >original.txt
# we are in /home/$USER/$VENAME/ # we are in /home/$USER/$VENAME/
ln -s ${TROGDIR} troggle ln -s ${TROGDIR} troggle
ln -s ${TROGDIR}/../expoweb expoweb ln -s ${TROGDIR}/../expoweb expoweb
ln -s ${TROGDIR}/../loser loser ln -s ${TROGDIR}/../loser loser
ln -s ${TROGDIR}/../drawings drawings ln -s ${TROGDIR}/../drawings drawings
#ln -s ${TROGDIR}/../expofiles expofiles #ln -s ${TROGDIR}/../expofiles expofiles
# fudge for philip's machine # fudge for philip's machine
if [ ! -d /mnt/d/EXPO ]; then if [ ! -d /mnt/d/EXPO ]; then
sudo mkdir /mnt/d sudo mkdir /mnt/d
sudo mount -t drvfs D: /mnt/d sudo mount -t drvfs D: /mnt/d
fi fi
if [ -d ${TROGDIR}/../expofiles ]; then if [ -d ${TROGDIR}/../expofiles ]; then
ln -s ${TROGDIR}/../expofiles expofiles ln -s ${TROGDIR}/../expofiles expofiles
else else
ln -s /mnt/d/EXPO/expofiles expofiles ln -s /mnt/d/EXPO/expofiles expofiles
fi fi
echo "### Setting file permissions.. may take a while.." echo "### Setting file permissions.. may take a while.."
git config --global --add safe.directory '*' git config --global --add safe.directory '*'
sudo chmod -R 777 * sudo chmod -R 777 *
echo "### links to expoweb, troggle etc. complete:" echo "### links to expoweb, troggle etc. complete:"
ls -tla ls -tla
echo "###" echo "###"
echo "### now installing ${TROGDIR}/${REQUIRE}" echo "### now installing ${TROGDIR}/${REQUIRE}"
echo "###" echo "###"
cat ${TROGDIR}/${REQUIRE} cat ${TROGDIR}/${REQUIRE}
# NOW THERE IS A PERMISSIONS FAILURE THAT DIDN'T HAPPEN BEFORE # NOW THERE IS A PERMISSIONS FAILURE THAT DIDN'T HAPPEN BEFORE
# seen on wsl2 as well as wsl1 # seen on wsl2 as well as wsl1
# which ALSO ruins EXISTING permissions ! # which ALSO ruins EXISTING permissions !
# Guessing it is to do with pip not liking non-standard py 3.11 installation on Ubuntu 22.04 # Guessing it is to do with pip not liking non-standard py 3.11 installation on Ubuntu 22.04
read -p "Press any key to resume ..." read -p "Press any key to resume ..."
$PIP install -r ${TROGDIR}/${REQUIRE} $PIP install -r ${TROGDIR}/${REQUIRE}
echo "### install from ${TROGDIR}/${REQUIRE} completed." echo "### install from ${TROGDIR}/${REQUIRE} completed."
echo '### ' echo '### '
$PIP install --pre django $PIP install --pre django
$PIP freeze > $REQUIRE $PIP freeze > $REQUIRE
# so that we can track requirements more easily with git # so that we can track requirements more easily with git
# because we do not install these with pip, but they are listed by the freeze command # because we do not install these with pip, but they are listed by the freeze command
# Now find out what we actually installed by subtracting the stuff venv installed anyway # Now find out what we actually installed by subtracting the stuff venv installed anyway
sort original.txt > 1 sort original.txt > 1
sort $REQUIRE >2 sort $REQUIRE >2
comm -3 1 2 --check-order | awk '{ print $1}'>fresh-$REQUIRE comm -3 1 2 --check-order | awk '{ print $1}'>fresh-$REQUIRE
rm 1 rm 1
rm 2 rm 2
# cp $REQUIRE requirements-$VENAME.txt # cp $REQUIRE requirements-$VENAME.txt
cp $REQUIRE troggle/$REQUIRE cp $REQUIRE troggle/$REQUIRE
$PIP list > installed-pip.list $PIP list > installed-pip.list
$PIP list -o > installed-pip-o.list $PIP list -o > installed-pip-o.list
REQ=installation-record REQ=installation-record
mkdir $REQ mkdir $REQ
mv original.txt $REQ mv original.txt $REQ
mv $REQUIRE $REQ mv $REQUIRE $REQ
mv original-pip.list $REQ mv original-pip.list $REQ
mv installed-pip.list $REQ mv installed-pip.list $REQ
mv installed-pip-o.list $REQ mv installed-pip-o.list $REQ
cp fresh-$REQUIRE ../$REQUIRE cp fresh-$REQUIRE ../$REQUIRE
mv fresh-$REQUIRE $REQ mv fresh-$REQUIRE $REQ
cp troggle/`basename "$0"` $REQ cp troggle/`basename "$0"` $REQ
$PYTHON --version $PYTHON --version
python --version python --version
echo "Django version:`django-admin --version`" echo "Django version:`django-admin --version`"
echo "### Now do echo "### Now do
'[sudo service mysql start]' '[sudo service mysql start]'
'[sudo service mariadb restart]' '[sudo service mariadb restart]'
'[sudo mysql_secure_installation]' '[sudo mysql_secure_installation]'
'cd ~/$VENAME' 'cd ~/$VENAME'
'source bin/activate' 'source bin/activate'
'cd troggle' 'cd troggle'
'django-admin' 'django-admin'
'python manage.py check' 'python manage.py check'
## this tests if you have set up ssh correcting. Refer to documentation https://expo.survex.com/handbook/computing/keyexchange.html ## 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. ## you need to follow the Linux instructions.
'ssh expo@expo.survex.com' 'ssh expo@expo.survex.com'
## the next tests will fail unless ~/expofiles is set correctly to a folder on your machine ## the next tests will fail unless ~/expofiles is set correctly to a folder on your machine
## the tests may ALSO fail because of ssh and permissions errors ## the tests may ALSO fail because of ssh and permissions errors
## So you will need to run ## So you will need to run
$sudo chown -Rhv philip:philip ~/$VENAME (if your username is philip) $sudo chown -Rhv philip:philip ~/$VENAME (if your username is philip)
# and then REBOOT (or at least, exit WSL and terminate and restart WSL) # and then REBOOT (or at least, exit WSL and terminate and restart WSL)
# because this chmod only takes effect then. # because this chmod only takes effect then.
'python manage.py test -v 2' 'python manage.py test -v 2'
'./pre-run.sh' (runs the tests again) './pre-run.sh' (runs the tests again)
'python databaseReset.py reset $VENAME' 'python databaseReset.py reset $VENAME'
'python manage.py runserver 0.0.0.0:8000 (and allow access when the firewall window pops up)' 'python manage.py runserver 0.0.0.0:8000 (and allow access when the firewall window pops up)'
" "
# if [ ! -d /mnt/d/expofiles ]; then # if [ ! -d /mnt/d/expofiles ]; then
# echo '### No valid expofiles directory on /mnt/d . Fix this before any tests will work.' # echo '### No valid expofiles directory on /mnt/d . Fix this before any tests will work.'
# fi # fi