diff options
Diffstat (limited to '_deploy/debian-laptops')
-rw-r--r-- | _deploy/debian-laptops/localsettings2023-04-05-cleansed.py | 160 | ||||
-rw-r--r-- | _deploy/debian-laptops/localsettings2023-04-05-secret.py | 160 | ||||
-rw-r--r-- | _deploy/debian-laptops/localsettingsserver2023-01-cleansed.py | 164 | ||||
-rw-r--r-- | _deploy/debian-laptops/os-trog.sh | 70 | ||||
-rw-r--r-- | _deploy/debian-laptops/settings2023-02-10.py | 147 | ||||
-rw-r--r-- | _deploy/debian-laptops/settings2023-04-23.py | 147 | ||||
-rw-r--r-- | _deploy/debian-laptops/venv-trog-crowley.sh | 173 |
7 files changed, 1021 insertions, 0 deletions
diff --git a/_deploy/debian-laptops/localsettings2023-04-05-cleansed.py b/_deploy/debian-laptops/localsettings2023-04-05-cleansed.py new file mode 100644 index 0000000..2544dff --- /dev/null +++ b/_deploy/debian-laptops/localsettings2023-04-05-cleansed.py @@ -0,0 +1,160 @@ +import os +import sys +import urllib.parse +from pathlib import Path + +"""Settings for a troggle installation which may vary among different +installations: for development or deployment, in a docker image or +python virtual environment (venv), on ubuntu, debian or in Windows +System for Linux (WSL), on the main server or in the potato hut, +using SQLite or mariaDB. + +It sets the directory locations for the major parts of the system so +that e.g. expofiles can be on a different filesystem. + +This file is included at the end of the main troggle/settings.py file so that +it overwrites defaults in that file. + +NOTE this file is vastly out of sync with troggle/_deploy/wsl/localsettings.py +which is the most recent version used in active maintenance. There should be +essential differences, but there and many, many non-essential differences which +should be eliminated for clarity and to use modern idioms. 8 March 2023. +""" + +print(" * importing troggle/localsettings.py") + +# DO NOT check this file into the git repo - it contains real passwords. + +EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever +#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME' : 'troggle', # Or path to database file if using sqlite3. + 'USER' : 'expo', # Not used with sqlite3. + 'PASSWORD' : '123456789012345', # Not used with sqlite3. Not a real password. + 'HOST' : '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT' : '', # Set to empty string for default. Not used with sqlite3. + } +} + + +EXPOUSER = 'expo' +EXPOUSERPASS = 'Not a real password' +EXPOADMINUSER = 'expoadmin' +EXPOADMINUSERPASS = 'Not a real password' +EXPOUSER_EMAIL = 'wookey@wookware.org' +EXPOADMINUSER_EMAIL = 'wookey@wookware.org' + +REPOS_ROOT_PATH = '/home/expo/' +sys.path.append(REPOS_ROOT_PATH) +sys.path.append(REPOS_ROOT_PATH + 'troggle') +# Define the path to the django app (troggle in this case) +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' + + +PHOTOS_YEAR = "2023" +# add in 358 when they don't make it crash horribly +NOTABLECAVESHREFS = [ "290", "291", "359", "264", "258", "204", "76", "107"] + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + PYTHON_PATH + "templates" + ], + 'OPTIONS': { + 'debug': 'DEBUG', + 'context_processors': [ + # django.template.context_processors.csrf, # is always enabled and cannot be removed, sets csrf_token + 'django.contrib.auth.context_processors.auth', # knowledge of logged-on user & permissions + 'core.context.troggle_context', # in core/troggle.py + 'django.template.context_processors.debug', + #'django.template.context_processors.request', # copy of current request, added in trying to make csrf work + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', # includes a variable MEDIA_URL + 'django.template.context_processors.static', # includes a variable STATIC_URL + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + ], + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', #For each app, inc admin, in INSTALLED_APPS, loader looks for /templates + # insert your own TEMPLATE_LOADERS here + ] + }, + }, +] + +PUBLIC_SITE = True + +# This should be False for normal running +DEBUG = False +CACHEDPAGES = True # experimental page cache for a handful of page types + + +# executables: +CAVERN = 'cavern' # for parsing .svx files and producing .3d files +SURVEXPORT = 'survexport' # for parsing .3d files and producing .pos files + +PV = "python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) +LIBDIR = Path(REPOS_ROOT_PATH) / 'lib' / PV + +EXPOWEB = Path(REPOS_ROOT_PATH + 'expoweb/') +SURVEYS = REPOS_ROOT_PATH +SURVEY_SCANS = REPOS_ROOT_PATH + 'expofiles/surveyscans/' +FILES = REPOS_ROOT_PATH + 'expofiles' +PHOTOS_ROOT = REPOS_ROOT_PATH + 'expofiles/photos/' + +TROGGLE_PATH = Path(__file__).parent +TEMPLATE_PATH = TROGGLE_PATH / 'templates' +MEDIA_ROOT = TROGGLE_PATH / 'media' +JSLIB_ROOT = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility + + +CAVEDESCRIPTIONS = EXPOWEB / "cave_data" +ENTRANCEDESCRIPTIONS = EXPOWEB / "entrance_data" + + +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' + + +#URL_ROOT = 'http://expo.survex.com/' +URL_ROOT = '/' +DIR_ROOT = Path("") #this should end in / if a value is given +EXPOWEB_URL = '/' +SURVEYS_URL = '/survey_scans/' + +REPOS_ROOT_PATH = Path(REPOS_ROOT_PATH) + +SURVEX_DATA = REPOS_ROOT_PATH / "loser" +DRAWINGS_DATA = REPOS_ROOT_PATH / "drawings" + + +EXPOFILES = REPOS_ROOT_PATH / "expofiles" +SCANS_ROOT = EXPOFILES / "surveyscans" +PHOTOS_ROOT = EXPOFILES / "photos" + +#EXPOFILES = urllib.parse.urljoin(REPOS_ROOT_PATH, 'expofiles/') +PHOTOS_URL = urllib.parse.urljoin(URL_ROOT, '/photos/') + +# MEDIA_URL is used by urls.py in a regex. See urls.py & core/views_surveys.py +MEDIA_URL = '/site_media/' + + +STATIC_URL = urllib.parse.urljoin(URL_ROOT , '/static/') # used by Django admin pages. Do not delete. +JSLIB_URL = urllib.parse.urljoin(URL_ROOT , '/javascript/') # always fails, try to revive it ? +# STATIC_ROOT removed after merging content into MEDIA_ROOT. See urls.py & core/views/surveys.py + +#TINY_MCE_MEDIA_ROOT = STATIC_ROOT + '/tiny_mce/' # not needed while TinyMCE not installed +#TINY_MCE_MEDIA_URL = STATIC_URL + '/tiny_mce/' # not needed while TinyMCE not installed + +LOGFILE = '/var/log/troggle/troggle.log' +IMPORTLOGFILE = '/var/log/troggle/import.log' + +# Sanitise these to be strings as Django seems to be particularly sensitive to crashing if they aren't +STATIC_URL = str(STATIC_URL) + "/" +MEDIA_URL = str(MEDIA_URL) + "/" + +print(" + finished importing troggle/localsettings.py") diff --git a/_deploy/debian-laptops/localsettings2023-04-05-secret.py b/_deploy/debian-laptops/localsettings2023-04-05-secret.py new file mode 100644 index 0000000..f73b512 --- /dev/null +++ b/_deploy/debian-laptops/localsettings2023-04-05-secret.py @@ -0,0 +1,160 @@ +import os +import sys +import urllib.parse +from pathlib import Path + +"""Settings for a troggle installation which may vary among different +installations: for development or deployment, in a docker image or +python virtual environment (venv), on ubuntu, debian or in Windows +System for Linux (WSL), on the main server or in the potato hut, +using SQLite or mariaDB. + +It sets the directory locations for the major parts of the system so +that e.g. expofiles can be on a different filesystem. + +This file is included at the end of the main troggle/settings.py file so that +it overwrites defaults in that file. + +NOTE this file is vastly out of sync with troggle/_deploy/wsl/localsettings.py +which is the most recent version used in active maintenance. There should be +essential differences, but there and many, many non-essential differences which +should be eliminated for clarity and to use modern idioms. 8 March 2023. +""" + +print(" * importing troggle/localsettings.py") + +# DO NOT check this file into the git repo - it contains real passwords. + +EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever +#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME' : 'troggle', # Or path to database file if using sqlite3. + 'USER' : 'expo', # Not used with sqlite3. + 'PASSWORD' : 'uFqP56B4XleeyIW', # Not used with sqlite3. + 'HOST' : '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT' : '', # Set to empty string for default. Not used with sqlite3. + } +} + + +EXPOUSER = 'expo' +EXPOUSERPASS = '161:gosser' +EXPOADMINUSER = 'expoadmin' +EXPOADMINUSERPASS = 'gosser:161' +EXPOUSER_EMAIL = 'wookey@wookware.org' +EXPOADMINUSER_EMAIL = 'wookey@wookware.org' + +REPOS_ROOT_PATH = '/home/expo/' +sys.path.append(REPOS_ROOT_PATH) +sys.path.append(REPOS_ROOT_PATH + 'troggle') +# Define the path to the django app (troggle in this case) +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' + + +PHOTOS_YEAR = "2023" +# add in 358 when they don't make it crash horribly +NOTABLECAVESHREFS = [ "290", "291", "359", "264", "258", "204", "76", "107"] + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + PYTHON_PATH + "templates" + ], + 'OPTIONS': { + 'debug': 'DEBUG', + 'context_processors': [ + # django.template.context_processors.csrf, # is always enabled and cannot be removed, sets csrf_token + 'django.contrib.auth.context_processors.auth', # knowledge of logged-on user & permissions + 'core.context.troggle_context', # in core/troggle.py + 'django.template.context_processors.debug', + #'django.template.context_processors.request', # copy of current request, added in trying to make csrf work + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', # includes a variable MEDIA_URL + 'django.template.context_processors.static', # includes a variable STATIC_URL + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + ], + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', #For each app, inc admin, in INSTALLED_APPS, loader looks for /templates + # insert your own TEMPLATE_LOADERS here + ] + }, + }, +] + +PUBLIC_SITE = True + +# This should be False for normal running +DEBUG = False +CACHEDPAGES = True # experimental page cache for a handful of page types + + +# executables: +CAVERN = 'cavern' # for parsing .svx files and producing .3d files +SURVEXPORT = 'survexport' # for parsing .3d files and producing .pos files + +PV = "python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) +LIBDIR = Path(REPOS_ROOT_PATH) / 'lib' / PV + +EXPOWEB = Path(REPOS_ROOT_PATH + 'expoweb/') +SURVEYS = REPOS_ROOT_PATH +SURVEY_SCANS = REPOS_ROOT_PATH + 'expofiles/surveyscans/' +FILES = REPOS_ROOT_PATH + 'expofiles' +PHOTOS_ROOT = REPOS_ROOT_PATH + 'expofiles/photos/' + +TROGGLE_PATH = Path(__file__).parent +TEMPLATE_PATH = TROGGLE_PATH / 'templates' +MEDIA_ROOT = TROGGLE_PATH / 'media' +JSLIB_ROOT = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility + + +CAVEDESCRIPTIONS = EXPOWEB / "cave_data" +ENTRANCEDESCRIPTIONS = EXPOWEB / "entrance_data" + + +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' + + +#URL_ROOT = 'http://expo.survex.com/' +URL_ROOT = '/' +DIR_ROOT = Path("") #this should end in / if a value is given +EXPOWEB_URL = '/' +SURVEYS_URL = '/survey_scans/' + +REPOS_ROOT_PATH = Path(REPOS_ROOT_PATH) + +SURVEX_DATA = REPOS_ROOT_PATH / "loser" +DRAWINGS_DATA = REPOS_ROOT_PATH / "drawings" + + +EXPOFILES = REPOS_ROOT_PATH / "expofiles" +SCANS_ROOT = EXPOFILES / "surveyscans" +PHOTOS_ROOT = EXPOFILES / "photos" + +#EXPOFILES = urllib.parse.urljoin(REPOS_ROOT_PATH, 'expofiles/') +PHOTOS_URL = urllib.parse.urljoin(URL_ROOT, '/photos/') + +# MEDIA_URL is used by urls.py in a regex. See urls.py & core/views_surveys.py +MEDIA_URL = '/site_media/' + + +STATIC_URL = urllib.parse.urljoin(URL_ROOT , '/static/') # used by Django admin pages. Do not delete. +JSLIB_URL = urllib.parse.urljoin(URL_ROOT , '/javascript/') # always fails, try to revive it ? +# STATIC_ROOT removed after merging content into MEDIA_ROOT. See urls.py & core/views/surveys.py + +#TINY_MCE_MEDIA_ROOT = STATIC_ROOT + '/tiny_mce/' # not needed while TinyMCE not installed +#TINY_MCE_MEDIA_URL = STATIC_URL + '/tiny_mce/' # not needed while TinyMCE not installed + +LOGFILE = '/var/log/troggle/troggle.log' +IMPORTLOGFILE = '/var/log/troggle/import.log' + +# Sanitise these to be strings as Django seems to be particularly sensitive to crashing if they aren't +STATIC_URL = str(STATIC_URL) + "/" +MEDIA_URL = str(MEDIA_URL) + "/" + +print(" + finished importing troggle/localsettings.py") diff --git a/_deploy/debian-laptops/localsettingsserver2023-01-cleansed.py b/_deploy/debian-laptops/localsettingsserver2023-01-cleansed.py new file mode 100644 index 0000000..a1e22ca --- /dev/null +++ b/_deploy/debian-laptops/localsettingsserver2023-01-cleansed.py @@ -0,0 +1,164 @@ +import os +import sys +import urllib.parse +from pathlib import Path + +"""Settings for a troggle installation which may vary among different +installations: for development or deployment, in a docker image or +python virtual environment (venv), on ubuntu, debian or in Windows +System for Linux (WSL), on the main server or in the potato hut, +using SQLite or mariaDB. + +It sets the directory locations for the major parts of the system so +that e.g. expofiles can be on a different filesystem, or /javascript/ can be in +a system-wide location rather than just a local directory. + +This file is included at the end of the main troggle/settings.py file so that +it overwrites defaults in that file. + +Read https://realpython.com/python-pathlib/ +Read https://adamj.eu/tech/2020/03/16/use-pathlib-in-your-django-project/ +""" + +print(" * importing troggle/localsettings.py") + +# DO NOT check this file into the git repo - it contains real passwords. + +EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever +#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME' : 'troggle', # Or path to database file if using sqlite3. + 'USER' : 'expo', # Not used with sqlite3. + 'PASSWORD' : '123456789012345', # Not used with sqlite3.Not the real password + 'HOST' : '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT' : '', # Set to empty string for default. Not used with sqlite3. + } +} + + +EXPOUSER = 'expo' +EXPOADMINUSER = 'expoadmin' +EXPOUSER_EMAIL = 'wookey@wookware.org' +EXPOADMINUSER_EMAIL = 'wookey@wookware.org' + +SECRET_KEY = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" +EXPOUSERPASS = "nope" +EXPOADMINUSERPASS = "nope" +EMAIL_HOST_PASSWORD = "nope" + +REPOS_ROOT_PATH = '/home/expo/' +sys.path.append(REPOS_ROOT_PATH) +sys.path.append(REPOS_ROOT_PATH + 'troggle') +# Define the path to the django app (troggle in this case) +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' +PHOTOS_YEAR = "2022" +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + PYTHON_PATH + "templates" + ], + 'OPTIONS': { + 'debug': 'DEBUG', + 'context_processors': [ + # django.template.context_processors.csrf, # is always enabled and cannot be removed, sets csrf_token + 'django.contrib.auth.context_processors.auth', # knowledge of logged-on user & permissions + 'core.context.troggle_context', # in core/troggle.py + 'django.template.context_processors.debug', + #'django.template.context_processors.request', # copy of current request, added in trying to make csrf work + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', # includes a variable MEDIA_URL + 'django.template.context_processors.static', # includes a variable STATIC_URL + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + ], + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', #For each app, inc admin, in INSTALLED_APPS, loader looks for /templates + # insert your own TEMPLATE_LOADERS here + ] + }, + }, +] + +PUBLIC_SITE = True + +# This should be False for normal running +DEBUG = True +CACHEDPAGES = True # experimental page cache for a handful of page types + +SURVEX_DATA = REPOS_ROOT_PATH + 'loser/' +DRAWINGS_DATA = REPOS_ROOT_PATH + 'drawings/' + +# executables: +CAVERN = 'cavern' # for parsing .svx files and producing .3d files +SURVEXPORT = 'survexport' # for parsing .3d files and producing .pos files + +EXPOWEB = REPOS_ROOT_PATH + 'expoweb/' +#SURVEYS = REPOS_ROOT_PATH +SCANS_ROOT = REPOS_ROOT_PATH + 'expofiles/surveyscans/' +FILES = REPOS_ROOT_PATH + 'expofiles' +PHOTOS_ROOT = REPOS_ROOT_PATH + 'expofiles/photos/' + +TROGGLE_PATH = Path(__file__).parent +TEMPLATE_PATH = TROGGLE_PATH / 'templates' +MEDIA_ROOT = TROGGLE_PATH / 'media' +JSLIB_ROOT = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility + + +CAVEDESCRIPTIONS = os.path.join(EXPOWEB, "cave_data") +ENTRANCEDESCRIPTIONS = os.path.join(EXPOWEB, "entrance_data") + +# CACHEDIR = REPOS_ROOT_PATH + 'expowebcache/' +# THREEDCACHEDIR = CACHEDIR + '3d/' +# THUMBNAILCACHE = CACHEDIR + 'thumbs' + +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' +PV = "python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) +LIBDIR = Path(REPOS_ROOT_PATH) / 'lib' / PV + +#Note that all these *_URL constants are not actually used in urls.py, they should be.. +#URL_ROOT = 'http://expo.survex.com/' +URL_ROOT = '/' +DIR_ROOT = ''#this should end in / if a value is given +EXPOWEB_URL = '/' +SCANS_URL = '/survey_scans/' +EXPOFILES = urllib.parse.urljoin(REPOS_ROOT_PATH, 'expofiles/') +PHOTOS_URL = urllib.parse.urljoin(URL_ROOT, '/photos/') + +# MEDIA_URL is used by urls.py in a regex. See urls.py & core/views_surveys.py +MEDIA_URL = '/site_media/' + + +STATIC_URL = urllib.parse.urljoin(URL_ROOT , '/static/') # used by Django admin pages. Do not delete. +JSLIB_URL = urllib.parse.urljoin(URL_ROOT , '/javascript/') # always fails, try to revive it ? + +#TINY_MCE_MEDIA_ROOT = STATIC_ROOT + '/tiny_mce/' # not needed while TinyMCE not installed +#TINY_MCE_MEDIA_URL = STATIC_URL + '/tiny_mce/' # not needed while TinyMCE not installed + +LOGFILE = '/var/log/troggle/troggle.log' +IMPORTLOGFILE = '/var/log/troggle/import.log' + +# add in 358 when they don't make it crash horribly +NOTABLECAVESHREFS = [ "290", "291", "359", "264", "258", "204", "76", "107"] + +# Sanitise these to be strings as all other code is expecting strings +# and we have not made the change to pathlib Path type in the other localsettings-* variants yet. +CAVEDESCRIPTIONS = os.fspath(CAVEDESCRIPTIONS) +ENTRANCEDESCRIPTIONS = os.fspath(ENTRANCEDESCRIPTIONS) +LOGFILE = os.fspath(LOGFILE) +#SURVEYS = os.fspath(SURVEYS) +EXPOWEB = os.fspath(EXPOWEB) +DRAWINGS_DATA = os.fspath(DRAWINGS_DATA) +SURVEX_DATA = os.fspath(SURVEX_DATA) +REPOS_ROOT_PATH = os.fspath(REPOS_ROOT_PATH) +TEMPLATE_PATH = os.fspath(TROGGLE_PATH) +MEDIA_ROOT = os.fspath(MEDIA_ROOT) +JSLIB_ROOT = os.fspath(JSLIB_ROOT) +SCANS_ROOT = os.fspath(SCANS_ROOT) +LIBDIR = os.fspath(LIBDIR) + +print(" + finished importing troggle/localsettings.py")
\ No newline at end of file diff --git a/_deploy/debian-laptops/os-trog.sh b/_deploy/debian-laptops/os-trog.sh new file mode 100644 index 0000000..3c5dd36 --- /dev/null +++ b/_deploy/debian-laptops/os-trog.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# Run this in a terminal in the troggle directory: 'bash os-trog.sh' +# On WSL, do Shift-click in the file explorer on the troggle folder to open a Linux command line +# 'Open Linux shell here' +echo 'Run this in a terminal in the troggle directory: "bash venv-trog.sh"' +cat /etc/os-release +# Expects an Ubuntu 22.04 relatively clean install. + +sudo apt install python-is-python3 -y +python --version : ensure python is an alias for python3 not python2.7 +sudo apt update -y +sudo apt dist-upgrade -y +sudo apt autoremove -y +sudo apt install sqlite3 -y +sudo apt install python3-pip -y + +# this installs a shed-load of other stuff: binutils etc.sudo apt install survex-aven +sudo apt install git openssh-client -y +# On a clean debian 11 (bullseye) installation with Xfce & ssh, + + #on ubuntu 20.04: + #Package sftp is not available, but is referred to by another package. + #This may mean that the package is missing, has been obsoleted, or + #is only available from another source + #E: Package 'sftp' has no installation candidate + + +# On Ubuntu 20.04, with python10, the pip install fails. +# So you need to get the pip from source +# sudo curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 +# but really you should be using 22.04 +# and also, isf using debian, +# sudo python3.10 -m pip install -U virtualenv + +# as debian does not install everything that ubuntu does, you need: +sudo useradd expo +sudo usermod -a -G sudo expo # to put expo in sudoers group, re-login required +sudo apt install python3-venv -y +sudo apt install python3-dev -y + +# default since 22.04 +# sudo apt install python3.10 +sudo apt install python3.10-venv -y +sudo apt install python3.10-dev -y +sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 + +sudo apt install mariadb-server -y +sudo apt install libmariadb-dev -y + +sudo python -m pip install --upgrade pip + +sudo apt install sftp -y +echo '###' +echo '### NOW INSTALLING tunnel and therion, go and have a cup of tea. Or a 3-course meal.' +echo '###' +sudo apt install tunnelx therion -y + +# Go to https://expo.survex.com/handbook/troggle/troglaptop.html#dbtools +# sudo service mysql start + +git config --global user.email "you@example.com" +git config --global user.name "Your Name" + +echo '###' +echo '### Currently set version of python' +python --version + +echo '###' +echo '### Now YOU have to configure the git settings for YOURSELF (not "expo")' + diff --git a/_deploy/debian-laptops/settings2023-02-10.py b/_deploy/debian-laptops/settings2023-02-10.py new file mode 100644 index 0000000..938c024 --- /dev/null +++ b/_deploy/debian-laptops/settings2023-02-10.py @@ -0,0 +1,147 @@ +""" +Django settings for troggle project. + +For more information on this file, see +https://docs.djangoproject.com/en/dev/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/dev/ref/settings/ +""" +# Imports should be grouped in the following order: + +# 1.Standard library imports. +# 2.Related third party imports. +# 3.Local application/library specific imports. +# 4.You should put a blank line between each group of imports. + + + +print("* importing troggle/settings.py") + +# default value, then gets overwritten by real secrets +SECRET_KEY = "not-the-real-secret-key-a#vaeozn0---^fj!355qki*vj2" + +GIT = "git" # command for running git + +# Note that this builds upon the django system installed +# global settings in +# django/conf/global_settings.py which is automatically loaded first. +# read https://docs.djangoproject.com/en/dev/topics/settings/ + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +# BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Django settings for troggle project. + +ALLOWED_HOSTS = ["*", "expo.survex.com", ".survex.com", "localhost", "127.0.0.1", "192.168.0.5"] + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) +MANAGERS = ADMINS + +# LOGIN_URL = '/accounts/login/' # this is the default value so does not need to be set + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +USE_TZ = True +TIME_ZONE = "Europe/London" + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = "en-uk" + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True +USE_L10N = True + +FIX_PERMISSIONS = [] + +# top-level survex file basename (without .svx) +SURVEX_TOPNAME = "1623-and-1626-no-schoenberg-hs" + + +# Caves for which survex files exist, but are not otherwise registered +# replaced (?) by expoweb/cave_data/pendingcaves.txt +# PENDING = ["1626-361", "2007-06", "2009-02", +# "2012-ns-01", "2012-ns-02", "2010-04", "2012-ns-05", "2012-ns-06", +# "2012-ns-07", "2012-ns-08", "2012-ns-12", "2012-ns-14", "2012-ns-15", "2014-bl888", +# "2018-pf-01", "2018-pf-02"] + +APPEND_SLASH = ( + False # never relevant because we have urls that match unknown files and produce an 'edit this page' response +) +SMART_APPEND_SLASH = True # not eorking as middleware different after Dj2.0 + + +LOGIN_REDIRECT_URL = "/" # does not seem to have any effect + +SECURE_CONTENT_TYPE_NOSNIFF = True +SECURE_BROWSER_XSS_FILTER = True +# SESSION_COOKIE_SECURE = True # if enabled, cannot login to Django control panel, bug elsewhere? +# CSRF_COOKIE_SECURE = True # if enabled only sends cookies over SSL +X_FRAME_OPTIONS = "DENY" # changed to "DENY" after I eliminated all the iframes e.g. /xmlvalid.html + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" # from Django 3.2 + +INSTALLED_APPS = ( + "django.contrib.admin", + "django.contrib.auth", # includes the url redirections for login, logout + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.admindocs", + "django.forms", # Required to customise widget templates + # 'django.contrib.staticfiles', # We put our CSS etc explicitly in the right place so do not need this + "troggle.core", +) + +FORM_RENDERER = "django.forms.renderers.TemplatesSetting" # Required to customise widget templates + +# See the recommended order of these in https://docs.djangoproject.com/en/dev/ref/middleware/ +# Note that this is a radically different onion architecture from earlier versions though it looks the same, +# see https://docs.djangoproject.com/en/dev/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware +# Seriously, read this: https://www.webforefront.com/django/middlewaredjango.html which is MUCH BETTER than the docs +MIDDLEWARE = [ + #'django.middleware.security.SecurityMiddleware', # SECURE_SSL_REDIRECT and SECURE_SSL_HOST # we don't use this + "django.middleware.gzip.GZipMiddleware", # not needed when expofiles and photos served by apache + "django.contrib.sessions.middleware.SessionMiddleware", # Manages sessions, if CSRF_USE_SESSIONS then it needs to be early + "django.middleware.common.CommonMiddleware", # DISALLOWED_USER_AGENTS, APPEND_SLASH and PREPEND_WWW + "django.middleware.csrf.CsrfViewMiddleware", # Cross Site Request Forgeries by adding hidden form fields to POST + "django.contrib.auth.middleware.AuthenticationMiddleware", # Adds the user attribute, representing the currently-logged-in user + "django.contrib.admindocs.middleware.XViewMiddleware", # this and docutils needed by admindocs + "django.contrib.messages.middleware.MessageMiddleware", # Cookie-based and session-based message support. Needed by admin system + "django.middleware.clickjacking.XFrameOptionsMiddleware", # clickjacking protection via the X-Frame-Options header + #'django.middleware.security.SecurityMiddleware', # SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SECURE_REFERRER_POLICY, and SECURE_SSL_REDIRECT + #'troggle.core.middleware.SmartAppendSlashMiddleware' # needs adapting after Dj2.0 +] + +ROOT_URLCONF = "troggle.urls" + +WSGI_APPLICATION = "troggle.wsgi.application" # change to asgi as soon as we upgrade to Django 3.0 + +ACCOUNT_ACTIVATION_DAYS = 3 + +# AUTH_PROFILE_MODULE = 'core.person' # used by removed profiles app ? + +QM_PATTERN = "\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" + +# Re-enable TinyMCE when Dj upgraded to v3. Also templates/editexpopage.html +# TINYMCE_DEFAULT_CONFIG = { +# 'plugins': "table,spellchecker,paste,searchreplace", +# 'theme': "advanced", +# } +# TINYMCE_SPELLCHECKER = False +# TINYMCE_COMPRESSOR = True + +TEST_RUNNER = "django.test.runner.DiscoverRunner" + +from localsettings import * + +# localsettings needs to take precedence. Call it to override any existing vars. diff --git a/_deploy/debian-laptops/settings2023-04-23.py b/_deploy/debian-laptops/settings2023-04-23.py new file mode 100644 index 0000000..938c024 --- /dev/null +++ b/_deploy/debian-laptops/settings2023-04-23.py @@ -0,0 +1,147 @@ +""" +Django settings for troggle project. + +For more information on this file, see +https://docs.djangoproject.com/en/dev/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/dev/ref/settings/ +""" +# Imports should be grouped in the following order: + +# 1.Standard library imports. +# 2.Related third party imports. +# 3.Local application/library specific imports. +# 4.You should put a blank line between each group of imports. + + + +print("* importing troggle/settings.py") + +# default value, then gets overwritten by real secrets +SECRET_KEY = "not-the-real-secret-key-a#vaeozn0---^fj!355qki*vj2" + +GIT = "git" # command for running git + +# Note that this builds upon the django system installed +# global settings in +# django/conf/global_settings.py which is automatically loaded first. +# read https://docs.djangoproject.com/en/dev/topics/settings/ + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +# BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Django settings for troggle project. + +ALLOWED_HOSTS = ["*", "expo.survex.com", ".survex.com", "localhost", "127.0.0.1", "192.168.0.5"] + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) +MANAGERS = ADMINS + +# LOGIN_URL = '/accounts/login/' # this is the default value so does not need to be set + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +USE_TZ = True +TIME_ZONE = "Europe/London" + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = "en-uk" + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True +USE_L10N = True + +FIX_PERMISSIONS = [] + +# top-level survex file basename (without .svx) +SURVEX_TOPNAME = "1623-and-1626-no-schoenberg-hs" + + +# Caves for which survex files exist, but are not otherwise registered +# replaced (?) by expoweb/cave_data/pendingcaves.txt +# PENDING = ["1626-361", "2007-06", "2009-02", +# "2012-ns-01", "2012-ns-02", "2010-04", "2012-ns-05", "2012-ns-06", +# "2012-ns-07", "2012-ns-08", "2012-ns-12", "2012-ns-14", "2012-ns-15", "2014-bl888", +# "2018-pf-01", "2018-pf-02"] + +APPEND_SLASH = ( + False # never relevant because we have urls that match unknown files and produce an 'edit this page' response +) +SMART_APPEND_SLASH = True # not eorking as middleware different after Dj2.0 + + +LOGIN_REDIRECT_URL = "/" # does not seem to have any effect + +SECURE_CONTENT_TYPE_NOSNIFF = True +SECURE_BROWSER_XSS_FILTER = True +# SESSION_COOKIE_SECURE = True # if enabled, cannot login to Django control panel, bug elsewhere? +# CSRF_COOKIE_SECURE = True # if enabled only sends cookies over SSL +X_FRAME_OPTIONS = "DENY" # changed to "DENY" after I eliminated all the iframes e.g. /xmlvalid.html + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" # from Django 3.2 + +INSTALLED_APPS = ( + "django.contrib.admin", + "django.contrib.auth", # includes the url redirections for login, logout + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.admindocs", + "django.forms", # Required to customise widget templates + # 'django.contrib.staticfiles', # We put our CSS etc explicitly in the right place so do not need this + "troggle.core", +) + +FORM_RENDERER = "django.forms.renderers.TemplatesSetting" # Required to customise widget templates + +# See the recommended order of these in https://docs.djangoproject.com/en/dev/ref/middleware/ +# Note that this is a radically different onion architecture from earlier versions though it looks the same, +# see https://docs.djangoproject.com/en/dev/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware +# Seriously, read this: https://www.webforefront.com/django/middlewaredjango.html which is MUCH BETTER than the docs +MIDDLEWARE = [ + #'django.middleware.security.SecurityMiddleware', # SECURE_SSL_REDIRECT and SECURE_SSL_HOST # we don't use this + "django.middleware.gzip.GZipMiddleware", # not needed when expofiles and photos served by apache + "django.contrib.sessions.middleware.SessionMiddleware", # Manages sessions, if CSRF_USE_SESSIONS then it needs to be early + "django.middleware.common.CommonMiddleware", # DISALLOWED_USER_AGENTS, APPEND_SLASH and PREPEND_WWW + "django.middleware.csrf.CsrfViewMiddleware", # Cross Site Request Forgeries by adding hidden form fields to POST + "django.contrib.auth.middleware.AuthenticationMiddleware", # Adds the user attribute, representing the currently-logged-in user + "django.contrib.admindocs.middleware.XViewMiddleware", # this and docutils needed by admindocs + "django.contrib.messages.middleware.MessageMiddleware", # Cookie-based and session-based message support. Needed by admin system + "django.middleware.clickjacking.XFrameOptionsMiddleware", # clickjacking protection via the X-Frame-Options header + #'django.middleware.security.SecurityMiddleware', # SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SECURE_REFERRER_POLICY, and SECURE_SSL_REDIRECT + #'troggle.core.middleware.SmartAppendSlashMiddleware' # needs adapting after Dj2.0 +] + +ROOT_URLCONF = "troggle.urls" + +WSGI_APPLICATION = "troggle.wsgi.application" # change to asgi as soon as we upgrade to Django 3.0 + +ACCOUNT_ACTIVATION_DAYS = 3 + +# AUTH_PROFILE_MODULE = 'core.person' # used by removed profiles app ? + +QM_PATTERN = "\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" + +# Re-enable TinyMCE when Dj upgraded to v3. Also templates/editexpopage.html +# TINYMCE_DEFAULT_CONFIG = { +# 'plugins': "table,spellchecker,paste,searchreplace", +# 'theme': "advanced", +# } +# TINYMCE_SPELLCHECKER = False +# TINYMCE_COMPRESSOR = True + +TEST_RUNNER = "django.test.runner.DiscoverRunner" + +from localsettings import * + +# localsettings needs to take precedence. Call it to override any existing vars. diff --git a/_deploy/debian-laptops/venv-trog-crowley.sh b/_deploy/debian-laptops/venv-trog-crowley.sh new file mode 100644 index 0000000..b2d0987 --- /dev/null +++ b/_deploy/debian-laptops/venv-trog-crowley.sh @@ -0,0 +1,173 @@ +#!/bin/bash +# Crowley has python 3.9.2 +# Taken from: 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-crowley.sh' +echo '-- DONT RUN THIS - messes up permissions!' + + +echo '-- Run this in a terminal in the real troggle directory: "bash venv-trog-crowley.sh"' +# use the script os-trog-crowley.sh + +# 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 + + +# NOW we set up troggle +PYTHON=python3.9 +VENAME=p9d4 # python3.x and django 4 +echo "** You are logged in as `id -u -n`" +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/" +TROGDIR=$(cd $(dirname $0) && pwd) +echo "-- Troggle folder (this script location): ${TROGDIR}" + +if [ -d requirements.txt ]; then + echo "-- No requirements.txt found. Copy it from your most recent installation." + exit 1 +fi +echo ## Using requirements.txt : +cat requirements.txt +echo ## + + +$PYTHON --version + +# 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 + +# NOW set up link from expo user folder +# needed for WSL2 +echo Creating links from Linux filesystem user +# These links only need making once, for many venv +cd ~ + +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)" + $PYTHON -m venv $VENAME +else + echo "## /$VENAME/ already exists ! Delete it first." + exit 1 +fi + + # Activate the virtual env and see what the default packages are +echo "### Activating $VENAME" + +cd $VENAME +echo "-- now in: ${PWD}" +source bin/activate +echo "### Activated." + # update local version of pip, more recent than OS version + # 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 + +echo "### installing later version of pip inside $VENAME" +$PYTHON -m pip install --upgrade pip +$PYTHON -m pip install --upgrade setuptools + +PIP=pip + +$PIP list > original-pip.list +$PIP freeze >original.txt + +# we are in /home/$USER/$VENAME/ +ln -s ${TROGDIR} troggle +ln -s ${TROGDIR}/../expoweb expoweb +ln -s ${TROGDIR}/../loser loser +ln -s ${TROGDIR}/../drawings drawings + +# fudge for philip's machine +if [ -d ${TROGDIR}/../expofiles ]; then + ln -s ${TROGDIR}/../expofiles expofiles +else + if [ ! -d /mnt/f/expofiles ]; then + sudo mkdir /mnt/f + sudo mount -t drvfs F: /mnt/f + else + ln -s /mnt/f/expofiles expofiles + fi +fi + +echo "### Setting file permissions.. may take a while.." +git config --global --add safe.directory '*' +#sudo chmod -R 0777 * + +echo "### links to expoweb, troggle etc. complete:" +ls -tla + +echo "###" +echo "### now installing ${TROGDIR}/requirements.txt" +echo "###" + +# NOW THERE IS A PERMISSIONS FAILURE THAT DIDN'T HAPPEN BEFORE +# seen on wsl2 as well as wsl1 +# which ALSO ruins EXISTING permissions ! +# Guessing it is to do with pip not liking non-standard py 3.11 installation on Ubuntu 22.04 + +$PIP install -r ${TROGDIR}/requirements.txt +echo '### install from requirements.txt completed.' +echo '### ' + +$PIP freeze > requirements.txt +# 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 +# Now find out what we actually installed by subtracting the stuff venv installed anyway +sort original.txt > 1 +sort requirements.txt >2 +comm -3 1 2 --check-order | awk '{ print $1}'>fresh-requirements.txt +rm 1 +rm 2 + +cp requirements.txt requirements-$VENAME.txt +cp requirements-$VENAME.txt troggle/requirements-$VENAME.txt + +$PIP list > installed-pip.list +$PIP list -o > installed-pip-o.list + +REQ=installation-record +mkdir $REQ +mv requirements-$VENAME.txt $REQ +mv original.txt $REQ +mv requirements.txt $REQ +mv original-pip.list $REQ +mv installed-pip.list $REQ +mv installed-pip-o.list $REQ +cp fresh-requirements.txt ../requirements.txt +mv fresh-requirements.txt $REQ +cp troggle/`basename "$0"` $REQ + + +$PYTHON --version +python --version +echo "Django version:`django-admin --version`" + +echo "### Now do + '[sudo service mysql start]' + '[sudo service mariadb restart]' + '[sudo mysql_secure_installation]' + 'cd ~/$VENAME' + 'source bin/activate' + 'cd troggle' + 'django-admin' + 'python 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 +## the tests may ALSO fail because of ssh and permissions errors +# Ran 85 tests in 83.492s +# FAILED (failures=5) +## So you will need to run +#$sudo chown -Rhv philip:philip ~/$VENAME (if your username is philip) +# and then REBOOT (or at least, exit WSL and terminate and restart WSL) +# because this chmod only takes effect then. + + './pre-run.sh' (runs the migrations and then the tests) + + 'python databaseReset.py reset $VENAME' + 'python manage.py runserver 0.0.0.0:8000 (and allow access when the firewall window pops up)' + " +if [ ! -d /mnt/f/expofiles ]; then +echo '### No valid expofiles directory. Fix this before any tests will work. +fi |