2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00
Mirror of Troggle Repo but with issue tracking etc. https://expo.survex.com
Go to file
2021-12-30 00:55:42 +00:00
_deploy remove unneeded LIBDIR 2021-10-24 19:16:01 +03:00
core msg that control panel not working 2021-12-30 00:55:42 +00:00
export Convert codebase for python3 usage 2020-05-24 20:56:27 +01:00
media jslib docum 2021-10-31 17:59:11 +02:00
parsers logbook cache reading broken - disabled 2021-11-11 22:57:49 +02:00
README Updated Troggle Article 2020-07-31 04:44:29 +01:00
templates msg that control panel not working 2021-12-30 00:55:42 +00:00
wiki-archaic rename wiki folder 2021-04-02 15:52:56 +01:00
__init__.py [svn] Initial troggle checkin 2009-05-13 05:13:38 +01:00
.gitignore fix unneeded runs of survex on survex mport 2021-11-05 22:59:54 +02:00
categories.json static files redone 2020-06-18 21:50:16 +01:00
confusables.json static files redone 2020-06-18 21:50:16 +01:00
databaseReset.py delete redundant logbook dump 2021-05-03 23:45:02 +01:00
deprecations.txt Docstrings for all modules 2021-04-13 01:37:42 +01:00
dump.py Module documentation docstrings 2020-07-18 16:23:54 +01:00
manage.py Dj1.11.29 running - trimmed unneeded packages 2021-03-17 21:09:44 +00:00
modelviz.py Convert codebase for python3 usage 2020-05-24 20:56:27 +01:00
pre-push.sh sanitize passwords before push to git on server 2021-10-23 21:07:16 +03:00
pre-run.sh logbook cache reading broken - disabled 2021-11-11 22:57:49 +02:00
README.txt testing WSL2 & docm addn 2021-12-05 17:11:12 +00:00
requirements3.2.txt rename scansfolder to wallet 2021-04-26 19:50:03 +01:00
requirements.txt rename scansfolder to wallet 2021-04-26 19:50:03 +01:00
reset-django.py Module documentation docstrings 2020-07-18 16:23:54 +01:00
security-warnings.txt improving README for a new dev install 2021-05-13 00:00:39 +03:00
settings.py Northings and Easting report 2021-05-07 22:42:10 +01:00
urls.py Better error msgs for bad slugs 2021-12-05 21:23:06 +00:00
wsgi.py 3dtopos to survexpos + comments 2020-07-20 22:53:26 +01:00

Updated 23 October 2021

Troggle is an application for caving expedition data management, 
originally created for use on Cambridge University Caving Club (CUCC)expeditions 
and licensed under the GNU Lesser General Public License.

Troggle has been forked into two projects. The original one is maintained by Aaron Curtis 
and was used for Erebus caves. The CUCC variant uses files as the definitive data, 
not the database and lives at http://expo.survex.com/repositories/troggle/.git/

For the server setup, see /_deploy/debian/wookey-exposerver-recipe.txt
and see http://expo.survex.com/handbook/troggle/serverconfig.html

Much material which was in this file has been moved to 
http://expo.survex.com/handbook/troggle/serverconfig.html

See copyright notices in
http://expo.survex.com/handbook/computing/contribute.html
and for context see
http://expo.survex.com/handbook/computing/onlinesystems.html 

Troggle setup
=============
0. read the very extensive online documentation and stop reading this README.
   http://expo.survex.com/handbook/troggle/troglaptop.html
   http://expo.survex.com/handbook/troggle/serverconfig.html
   http://expo.survex.com/handbook/troggle/trogdangoup.html
   and at troggle/debian/serversetup 
1. set up the ssh key-exchange with the git server so you can clone troggle
   http://expo.survex.com/handbook/computing/keyexchange.html

Setting up directories
----------------------
see  http://expo.survex.com/handbook/troggle/troglaptop.html and 
http://expo.survex.com/handbook/troggle/serverconfig.html

Next, you need to fill in your local settings. Copy _deploy/WSL/localsettingsWSL.py 
to a new file called localsettings.py and edit it and settings.py to match
your machine's file locations. 
Follow the instructions contained in the file to fill out your settings.

{ in _deploy/old/ we have these which are all very out of date:
  localsettings-expo-live.py is the python2.7 settings for the server.
  localsettingsubuntu.py
  localsettingsdocker.py
  localsettingswindows.py
  localsettingspotatohut.py
}

Python3, Django, and Database setup
-----------------------------------
We are now using Django 2.2.19 
We are installing with python3.7

Install Django using pip, not with apt, on your test system.
Conventionally on our main master expo server we install everything that we can as debian packages, not using pip.

[installation instructions removed - now in http://expo.survex.com/handbook/troggle/troglaptop.html ]

[venv description removed - read it in http://expo.survex.com/handbook/troggle/troglaptop.html ]

Automatic Provisioning and Configuration
----------------------------------------
We don't do this - yet.
We don't even have a bash script.
The most appropriate configuration tools today (2021) appear to be Bolt or Ansible
https://puppet.com/docs/bolt/latest/bolt.html (declarative, local)
https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html (procedural, remote)
https://puppet.com/blog/automating-from-zero-to-something/ 

We don't need anything for the deploy server itself, but we could do with something for setting
up test servers quickly to help get newbie developers up to speed faster. But learning a new tool
creates a barrier in itself. This is one reason most of us don't use Docker.

CSS and media files
-------------------
Temporarily we are not using the STATICFILES capability but are instead
serving css files from troggle/media/.. (see urls.py) using 
view_surveys.cssfilessingle 
i.e.
cssfilessingle() in core/view_surveys.py

Setting up survex
-----------------
You need to have survex installed as the command line tools 'cavern' is
used as part of the survex import process.
$ sudo apt install survex

Setting up tables and importing survey data
-------------------------------------------
Run 
$ sudo python databaseReset.py
from the troggle directory will give you instructions.

[ NB Adding a new year/expedition requires adding a column to the
folk/folk.csv table - a year doesn't exist until that is done.]

Database
--------
If you want to use MySQL or Postgresql, download and install them. 
However, you can also use Django with sqlite3

MariaDB database
----------------
Start it up with
$ sudo mysql -u -p
when it will prompt you to type in the password. Get this by reading the settings.py file in use on the server.
then
> CREATE DATABASE troggle;
> use troggle;
> exit;

Note the semicolons.

You can check the status of the db service:
$ sudo systemctl status mysql

You can start and stop the db service with
$ sudo systemctl restart mysql.service
$ sudo systemctl stop mysql.service
$ sudo systemctl start mysql.service

While logged in at a terminal session as expo on expo.survex.,com

$ mysql -h localhost -u expo -p<password>
will get you the MariasDb command prompt: https://www.hostwinds.com/guide/how-to-use-mysql-mariadb-from-command-line/

then (Note the SEMICOLONS !):
>drop database troggle;
>create database troggle;
>quit
Somewhere I have notes for the GRANT PRIVS type runes...

Ah yes:
CREATE DATABASE troggle;
GRANT ALL PRIVILEGES ON troggle.* TO 'expo'@'localhost' IDENTIFIED BY 'somepassword'; FLUSH PRIVILEGES; (at mysql root prompt)

(explained on https://chartio.com/resources/tutorials/how-to-grant-all-privileges-on-a-database-in-mysql/)
(but you need to create the database too)

The GRANT ALL PRIVILEGES  bit requires you to logon in to MariaDB as root. sudo doesn't cut it.
these permissions are set in a different 'info' database which usually is untouched even if database troggle gets creamed.


PERMISSIONS
https://linuxize.com/post/usermod-command-in-linux/

sudo usermod -a expo www-data
adds expo to the www-data group which is what the webserver uses, and thus so the user troggle is acting as when running live.

So all the /loser/ .svx files need to have permissions like this (664)
-rw-rw-r-- expo www-data
so that the online editing system for SVX files works.
The same goes for /expoweb/ files, so that "edit this page" works and the New Cave
and New Entrance forms work.

sudo usermod -a expo expocvs
the expocvs group is used for git & hg

all the users should be in this group


Running a Troggle server with Apache
------------------------------------
Troggle also needs these aliases to be configured. These are set in 
/home/expo/config/apache/expo.conf
on the expo server.

At least these need setting:
DocumentRoot              /home/expo/expoweb
WSGIScriptAlias        /  /home/expo/troggle/wsgi.py
<Directory /home/expo/troggle>
	<Files wsgi.py>
		Require all granted
	</Files>
</Directory>

Alias       /expofiles    /home/expo/expofiles
Alias       /photos       /home/expo/webphotos
Alias       /map          /home/expo/expoweb/map
Alias       /javascript   /usr/share/javascript
Alias       /static/      /home/expo/static/
ScriptAlias /repositories /home/expo/config/apache/services/hgweb/hgweb.cgi

(The last is just for mercurial which will be remoived during 2020).

These two are not necessary as Django will serve these (see urls.py), but 
it may be faster for apache to serve them first:
Alias       /expofiles    /home/expo/expofiles
Alias       /static/      /home/expo/static/


Unlike the django "manage.py runserver" method, apache requires a restart before it will use
any changed files:

sudo service apache2 restart

Olly's comments 20 July 2020:
olly: looking at /lib/systemd/system/apache2.service suggests so

olly: ExecStart=/usr/sbin/apachectl start
olly: ExecStop=/usr/sbin/apachectl stop
olly: ExecReload=/usr/sbin/apachectl graceful


Experimental additions
----------------------
These are untried tools which help us document how troggle works.

pip install pygraphviz 
pip install pyparsing pydot # installs fine
django extension graph_models # https://django-extensions.readthedocs.io/en/latest/graph_models.html