One-command installers: VPS (Let's Encrypt, MariaDB) and intranet (internal CA, SQLite); SQLite backend option, SQLite backups, doctor intranet checks, bilingual docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-17 15:38:35 +02:00
parent a60d9265e8
commit 4373032582
28 changed files with 1039 additions and 29 deletions
+4
View File
@@ -34,6 +34,10 @@ A complete nginx configuration example (MIME types, headers, cache, API) is prov
## Installing on a VPS
!!! tip "One command"
`./deploy/install_vps.sh` (public VPS) and `./deploy/install_intranet.sh` (school network, no public domain) do
everything end to end: see [The installers](installers.md). What follows details the steps.
The server is set up **from a clone of the repository, directly on the VPS, as root**: the site is built in place,
then published as successive versions with an atomic switch of the `current` link. The repository is cloned under the
name `PyQuest` (for example `/opt/PyQuest`, outside `/root` and `/home`).
+85
View File
@@ -0,0 +1,85 @@
# The installers: VPS and intranet
Two scripts do, **in one command**, everything you would otherwise do by hand. Run them **as root on the server**, from a
clone of the repository (outside `/root` and `/home`, e.g. `/opt/PyQuest`), on **Debian or Ubuntu**. They are
**idempotent**: after an interruption, run the same command again. `--dry-run` prints everything that would be done
without changing anything; `--yes` removes the questions (for automation).
| | Public VPS | Intranet (school network) |
|---|---|---|
| Script | `deploy/install_vps.sh` | `deploy/install_intranet.sh` |
| Site address | a public **domain name** | an internal DNS name **or an IP address** |
| HTTPS | **Let's Encrypt** certificate (renewed by certbot) | **internal certificate authority** created by the installer |
| Database | **MariaDB** | **SQLite** (one file, nothing to administer) |
| Server Internet access | permanent | during installation only (packages, Python engine) |
| Computers must… | nothing | trust the authority, **once** |
## Installing on a VPS
Requirements: the domain name already points to the VPS (A/AAAA record), ports 80 and 443 are free or held by nginx, an
e-mail address for Let's Encrypt.
```bash
git clone git@github.com:deunix-educ/PyQuest.git /opt/PyQuest && cd /opt/PyQuest
./deploy/install_vps.sh --domain pyquest.example.org --email you@example.org --dry-run # simulation
./deploy/install_vps.sh --domain pyquest.example.org --email you@example.org
```
The installer chains: pre-flight checks (does the name resolve? are the ports free?), `server_setup.sh` (packages, user,
Python environment, nginx, certificate and its renewal), MariaDB installation if missing (after confirmation),
`db_setup.sh` (database, user, generated password; the MariaDB administrator's password is asked for), service start,
creation of the first administrator, `server_update.sh` (build and publish), daily backup, and a final diagnosis.
Options: `--db-admin-user`, `--port`, `--no-admin`.
## Installing on an intranet
Requirements: a Debian/Ubuntu server on the network (a small machine is enough), reachable by the computers, with
Internet access **during installation**. Decide how computers will reach it: a name (to be declared in the network's DNS)
and/or its **fixed** IP address.
```bash
git clone git@github.com:deunix-educ/PyQuest.git /opt/PyQuest && cd /opt/PyQuest
./deploy/install_intranet.sh --host pyquest.school.lan,192.168.1.20 --dry-run
./deploy/install_intranet.sh --host pyquest.school.lan,192.168.1.20
```
The installer creates the certificate authority (`/etc/pyquest/tls/ca.crt`) and the server certificate for **each name
and address** given, configures nginx (HTTPS, protected level editor, administration), the SQLite database
(`/var/lib/pyquest/db.sqlite3`), the service, the site publication and two scheduled tasks: daily backup and monthly
renewal of the server certificate. It offers to create the first administrator.
### Why HTTPS, even on an intranet?
Without HTTPS (other than `localhost`), the browser disables the service worker (hence offline mode and installing the
application) and the isolation that allows stopping an infinite loop and using `input()`. The installer sets this up once
and for all; computers only need to **trust the school's authority**.
### Trusting the authority on computers
- **One computer at a time**: open `http://pyquest.school.lan/ca` (page served by the server), download `pyquest-ca.crt`
and follow the page's instructions (Windows, Firefox, Linux, Android, iOS).
- **A whole fleet**: the network administrator imports `pyquest-ca.crt` into the trusted root authorities through group
policy (Windows) or the device management tool. Firefox follows the system store when the
`security.enterprise_roots.enabled` option is on.
This is **done once**: the server certificate is reissued automatically, but the authority (valid for ten years) does not
change.
### Keep in mind
- **Back up `/etc/pyquest/tls/ca.key`** off the server, somewhere safe: it is the authority's key. Losing it means
redoing the trust on every computer; leaking it would allow impersonating the server. Never distribute it: only
`ca.crt` and the `/ca` page are public.
- **Accounts**: students have no account (progress stays in their browser, synchronisation is optional). Teacher-authors
are created in `https://pyquest.school.lan/api/admin/`.
- **Shared computers**: progress is stored per browser and per session; on a shared computer, use one browser profile per
student, or the progress backup / synchronisation.
- **Updates**: `cd /opt/PyQuest && git pull && ./scripts/server_update.sh` (Internet access is only needed for `git pull`
and a possible new Python engine).
- **Diagnosis**: `./scripts/vps_doctor.sh` (recognises the intranet installation: certificate validity, renewal task,
SQLite database, backups).
- **Restoring a backup**: stop the service (`systemctl stop pyquest`), `gunzip < backup.sqlite.gz >
/var/lib/pyquest/db.sqlite3`, `chown pyquest:pyquest` the file, `systemctl start pyquest`.
Operating details (updates, rollback, troubleshooting) are those of [Going live and operations](operations.md), whose scripts
the intranet installation shares.
+1 -1
View File
@@ -1,6 +1,6 @@
# Going live and operations
Procedure to install PyQuest on a VPS, then run it. Everything is done **on the VPS, as root, from a clone of the
The installers ([VPS and intranet](installers.md)) automate everything below. Procedure to install PyQuest on a VPS, then run it. Everything is done **on the VPS, as root, from a clone of the
repository** (folder name: `PyQuest`). The scripts are tested without a server; what touches the VPS itself could not be
tried for real before the first installation: start with `--dry-run` and `vps_doctor.sh`.
+4
View File
@@ -35,6 +35,10 @@ Un exemple complet de configuration nginx (types MIME, en-têtes, cache, API) es
## Installer sur un VPS
!!! tip "Une seule commande"
`./deploy/install_vps.sh` (VPS public) et `./deploy/install_intranet.sh` (réseau d'un lycée, sans domaine public)
font tout d'un bout à l'autre : voir [Les installateurs](installers.md). Ce qui suit détaille les étapes.
Le serveur se met en place **depuis un clone du dépôt, directement sur le VPS, en root** : le site est construit sur
place, puis publié par versions successives avec bascule atomique du lien `current`. Le dépôt se clone sous le nom
`PyQuest` (par exemple `/opt/PyQuest`, hors de `/root` et `/home`).
+85
View File
@@ -0,0 +1,85 @@
# Les installateurs : VPS et intranet
Deux scripts font, **d'une seule commande**, tout ce qu'on ferait à la main. Ils se lancent **en root sur le serveur**,
depuis un clone du dépôt (hors de `/root` et `/home`, par exemple `/opt/PyQuest`), sur **Debian ou Ubuntu**. Ils sont
**idempotents** : après une interruption, on relance la même commande. `--dry-run` affiche tout ce qui serait fait sans
rien modifier ; `--yes` supprime les questions (pour automatiser).
| | VPS public | Réseau intranet (lycée) |
|---|---|---|
| Script | `deploy/install_vps.sh` | `deploy/install_intranet.sh` |
| Adresse du site | un **nom de domaine** public | un nom du DNS interne **ou une adresse IP** |
| HTTPS | certificat **Let's Encrypt** (renouvelé par certbot) | **autorité de certification interne** créée par l'installateur |
| Base de données | **MariaDB** | **SQLite** (un fichier, rien à administrer) |
| Accès à Internet du serveur | permanent | pendant l'installation seulement (paquets, moteur Python) |
| Les postes doivent… | rien | faire confiance à l'autorité, **une fois** |
## Installer sur un VPS
Prérequis : le nom de domaine pointe déjà vers le VPS (enregistrement A/AAAA), les ports 80 et 443 sont libres ou tenus
par nginx, une adresse e-mail pour Let's Encrypt.
```bash
git clone git@github.com:deunix-educ/PyQuest.git /opt/PyQuest && cd /opt/PyQuest
./deploy/install_vps.sh --domain pyquest.example.org --email toi@example.org --dry-run # simulation
./deploy/install_vps.sh --domain pyquest.example.org --email toi@example.org
```
L'installateur enchaîne : contrôles préalables (le nom se résout-il ? les ports sont-ils libres ?), `server_setup.sh`
(paquets, utilisateur, environnement Python, nginx, certificat et son renouvellement), installation de MariaDB si elle
manque (après confirmation), `db_setup.sh` (base, utilisateur, mot de passe généré ; le mot de passe de l'administrateur
MariaDB est demandé), démarrage du service, création du premier administrateur, `server_update.sh` (construction et
publication), sauvegarde quotidienne, et un diagnostic final. Options : `--db-admin-user`, `--port`, `--no-admin`.
## Installer dans un réseau intranet
Prérequis : un serveur Debian/Ubuntu du réseau (une petite machine suffit), joignable par les postes, avec un accès à
Internet **le temps de l'installation**. Choisir comment les postes l'appelleront : un nom (à déclarer dans le DNS du
réseau) et/ou son adresse IP **fixe**.
```bash
git clone git@github.com:deunix-educ/PyQuest.git /opt/PyQuest && cd /opt/PyQuest
./deploy/install_intranet.sh --host pyquest.lycee.local,192.168.1.20 --dry-run
./deploy/install_intranet.sh --host pyquest.lycee.local,192.168.1.20
```
L'installateur crée l'autorité de certification (`/etc/pyquest/tls/ca.crt`) et le certificat du serveur pour **chaque nom
et adresse** donnés, configure nginx (HTTPS, éditeur de niveaux protégé, administration), la base SQLite
(`/var/lib/pyquest/db.sqlite3`), le service, la publication du site et deux tâches planifiées : sauvegarde quotidienne et
renouvellement mensuel du certificat du serveur. Il propose de créer le premier administrateur.
### Pourquoi HTTPS, même en intranet ?
Sans HTTPS (hors `localhost`), le navigateur désactive le service worker (donc le mode hors ligne et l'installation de
l'application) et l'isolation qui permet d'interrompre une boucle infinie et d'utiliser `input()`. L'installateur règle
cela une fois pour toutes ; il faut seulement que les postes **fassent confiance à l'autorité de l'établissement**.
### Faire confiance à l'autorité sur les postes
- **Un poste à la fois** : ouvrir `http://pyquest.lycee.local/ca` (page fournie par le serveur), télécharger
`pyquest-ca.crt` et suivre les instructions de la page (Windows, Firefox, Linux, Android, iOS).
- **Tout un parc** : l'administrateur du réseau importe `pyquest-ca.crt` dans les autorités racines de confiance par la
stratégie de groupe (Windows) ou l'outil de gestion des postes. Firefox suit le magasin du système si l'option
`security.enterprise_roots.enabled` est activée.
Cette opération ne se fait **qu'une fois** : le certificat du serveur est réémis automatiquement, mais l'autorité (valable
dix ans) ne change pas.
### À garder en tête
- **Sauvegarder `/etc/pyquest/tls/ca.key`** hors du serveur, en lieu sûr : c'est la clé de l'autorité. La perdre oblige à
refaire la confiance sur tous les postes ; la divulguer permettrait de se faire passer pour le serveur. Ne jamais la
distribuer : seuls `ca.crt` et la page `/ca` sont publics.
- **Comptes** : les élèves n'ont pas de compte (la progression reste dans leur navigateur, la synchronisation est
facultative). Les enseignants-auteurs se créent dans `https://pyquest.lycee.local/api/admin/`.
- **Postes partagés** : la progression est enregistrée par navigateur et par session ; sur un poste commun, utiliser un
profil de navigateur par élève, ou la sauvegarde / synchronisation de la progression.
- **Mises à jour** : `cd /opt/PyQuest && git pull && ./scripts/server_update.sh` (accès à Internet requis seulement pour
`git pull` et un éventuel nouveau moteur Python).
- **Diagnostic** : `./scripts/vps_doctor.sh` (reconnaît l'installation intranet : validité du certificat, tâche de
renouvellement, base SQLite, sauvegardes).
- **Restauration d'une sauvegarde** : arrêter le service (`systemctl stop pyquest`), `gunzip < sauvegarde.sqlite.gz >
/var/lib/pyquest/db.sqlite3`, `chown pyquest:pyquest` sur le fichier, `systemctl start pyquest`.
Les détails d'exploitation (mises à jour, retour arrière, dépannage) sont ceux de [Mise en service et
exploitation](operations.md), dont l'intranet partage les scripts.
+1 -1
View File
@@ -1,6 +1,6 @@
# Mise en service et exploitation
Marche à suivre pour installer PyQuest sur un VPS, puis l'exploiter. Tout se fait **sur le VPS, en root, depuis un clone
Les installateurs ([VPS et intranet](installers.md)) automatisent tout ce qui suit. Marche à suivre pour installer PyQuest sur un VPS, puis l'exploiter. Tout se fait **sur le VPS, en root, depuis un clone
du dépôt** (nom du dossier : `PyQuest`). Les scripts sont testés sans serveur ; ce qui touche le VPS lui-même n'a pas pu
être essayé en réel avant la première installation : commence par `--dry-run` et `vps_doctor.sh`.