Add install.sh / upgrade.sh to automate the documented deployment steps

Keeps the traditional pip+systemd+nginx deployment (no Docker, per the
original decision) but automates the manual steps already in
docs/install.md instead of leaving them as copy-paste instructions:

- scripts/install.sh: creates the system user, virtualenv, generates
  .env (auto SECRET_KEY, prompts for domain/SQLite-vs-Postgres —
  non-interactive via EVECTION_ALLOWED_HOSTS/EVECTION_DATABASE_URL/etc
  for scripted provisioning), migrates, collects static files, installs
  the systemd units (sed-substituted for the actual install path/user
  rather than hardcoded to /opt/evection), and optionally sets up nginx +
  certbot. Safe to re-run — skips what's already done rather than
  redoing it, and never overwrites an existing .env.
- scripts/upgrade.sh: git pull, reinstall, migrate, collectstatic,
  restart whichever of the three services are actually present (handles
  the combined worker+beat deployment variant too).

docs/install.md now leads with the script as the recommended path, with
the existing step-by-step instructions kept below for anyone who wants
to understand or customize what it's doing.

Verified: shellcheck clean on both scripts (via a throwaway shellcheck-py
venv, since neither apt nor pip --user were available non-interactively);
the systemd-unit and nginx-config sed substitutions produce correct
output against the real template files; the generated .env format
round-trips through `manage.py check` under config.settings.prod without
error. Did not actually run install.sh against a real system — that
creates a system user and installs systemd units, which needs the
person deploying it to run (and review) themselves.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 22:11:18 -06:00
1 parent 20dd61e938
commit a89f651a71
3 files changed
+287

No files matched your search

+32
View File
@@ -8,6 +8,28 @@ below runs directly on the host.
Both SQLite and PostgreSQL are fully supported. Steps that differ are marked
**SQLite** / **Postgres**; everything else applies to both.
## Quick install
Once the prerequisites below are in place, `scripts/install.sh` automates
everything from "create a system user" through "systemd units are running" —
and optionally nginx + a Let's Encrypt certificate too. It's interactive
(asks for your domain and database choice) and safe to re-run.
```bash
sudo mkdir -p /opt/evection
sudo git clone <your-fork-or-release-url> /opt/evection/app
cd /opt/evection/app
sudo ./scripts/install.sh
```
(The script creates the `evection` system user itself and takes ownership of
the checkout — you don't need to create it or clone as that user first.)
The rest of this document explains what that script does, step by step, if
you want to run it manually, customize something, or just understand the
deployment before trusting a script with root. Either way, read sections 1
and 4 below first — prerequisites and what `.env` controls.
## 1. Prerequisites
- Python 3.11 or 3.12
@@ -189,6 +211,16 @@ and losing it invalidates every existing session and signed cookie.
## Upgrading
```bash
cd /opt/evection/app
sudo ./scripts/upgrade.sh
```
That pulls the latest code (if `/opt/evection/app` is a git checkout —
extract a release tarball over it yourself first otherwise), reinstalls
dependencies, migrates, collects static files, and restarts whichever of
the three services are actually installed. Equivalent by hand:
```bash
cd /opt/evection/app
sudo -u evection -H git pull # or: extract the new release over this directory