Commit Graph
5 Commits
Author SHA1 Message Date
ksmithandClaude Sonnet 5 78611c0eae Check for a working venv module before install.sh does anything else
On Debian/Ubuntu, python3-venv (ensurepip support) is a separate package
from python3 itself, and apt installing just python3 leaves venv creation
failing partway through install.sh — after the system user, chown, and
git checkout have all already happened. Check for it up front alongside
the Python version check, and document the apt package in install.md's
prerequisites.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 08:51:28 -06:00
ksmithandClaude Sonnet 5 50d2ba9404 Mark the app checkout as a safe.directory for root's git commands
install.sh chowns $APP_DIR to the service user, but its own (and
upgrade.sh's) git fetch/checkout steps run as root per the previous fix —
git refuses that combination by default ("detected dubious ownership"),
which is exactly what happens re-running install.sh after an earlier run
got far enough to chown the checkout. Add the directory to root's
safe.directory list before touching it with git.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 08:49:37 -06:00
ksmithandClaude Sonnet 5 8c23cc631c Fix install.sh failing with permission denied creating the venv
EVECTION_HOME (the venv's parent directory, e.g. /opt/evection) was never
chowned to the service user — only the app checkout inside it was — so
venv creation failed with Permission denied whenever EVECTION_HOME was
created by root before running the script (the documented quick-install
steps do exactly that: mkdir + git clone as root, then run install.sh).

Also run the release-tag git fetch/checkout as root instead of
sudo -u $EVECTION_USER in both install.sh and upgrade.sh: the service
user has no reason to have its own git credentials configured, so running
as it just means the private repo's auth prompt hangs the script (as seen
on this install) or silently fails. Root already has working credentials
from the initial clone. Added GIT_TERMINAL_PROMPT=0 so a credential
problem fails fast instead of hanging on a prompt either way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 08:39:09 -06:00
ksmithandClaude Sonnet 5 2e4674a18f Make the updater deploy tagged releases, like ds-chat's upgrade.sh
scripts/upgrade.sh now fetches tags and does a detached-HEAD checkout of
the latest one (git tag --sort=-creatordate | head -n1), matching the
ds-chat project's deploy/upgrade.sh exactly rather than a plain git pull
on whatever branch happened to be checked out. Errors clearly if the repo
has no tags yet (true for Evection right now — nothing to deploy until a
release is tagged and pushed), and no-ops cleanly if already on the
latest tag. scripts/install.sh does the same tag pin on first install
(falling back to whatever's checked out if no tags exist yet), so the
very first deploy is consistent with every upgrade after it.

Added a GET /health/ endpoint (apps.core.views.health) that checks DB
connectivity and is exempt from the first-run setup redirect, for the
upgrade script's post-restart verification (curled over the gunicorn
unix socket, same as ds-chat's curl-based check) and for any external
uptime monitor.

While wiring the setup-wizard exemption for /health/, found that
SetupWizardMiddleware._a_user_exists's reset fixture was scoped only to
apps/accounts/tests.py, so a test anywhere else that creates a user and
makes a request could leak a stale "a user exists" into later test files
with no reset — confirmed this concretely by temporarily breaking the new
exemption and watching the "works before setup" test still pass purely
from accounts/tests.py leaving the module-order-adjacent apps/articles
tests to poison the shared class attribute. Moved the fixture to a new
top-level conftest.py so it's autouse across every test file, which also
makes the new health-check test meaningful regardless of run order.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 22:15:37 -06:00
ksmithandClaude Sonnet 5 a89f651a71 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>
2026-10-30 22:11:18 -06:00