diff --git a/README.md b/README.md index 564412c..de09169 100644 --- a/README.md +++ b/README.md @@ -102,23 +102,20 @@ uv run --no-sync python ingest.py Watch the logs. It will process all historical messages, then listen for new ones. Press Ctrl-C to stop. -## Install as a systemd service +## Install as a systemd user service ```bash -# Create a dedicated user -sudo useradd -r -s /bin/false matrix-paperless-ingest +# Enable lingering so the service starts at boot without requiring login +loginctl enable-linger -# Copy the project -sudo cp -r . /opt/matrix-paperless-ingest -sudo chown -R matrix-paperless-ingest:matrix-paperless-ingest /opt/matrix-paperless-ingest - -# Install and start the service -sudo cp paperless-ingest.service /etc/systemd/system/ -sudo systemctl daemon-reload -sudo systemctl enable --now paperless-ingest +# Install the service +mkdir -p ~/.config/systemd/user +cp matrix-paperless-ingest.service ~/.config/systemd/user/ +systemctl --user daemon-reload +systemctl --user enable --now matrix-paperless-ingest # Check logs -sudo journalctl -u paperless-ingest -f +journalctl --user -u matrix-paperless-ingest -f ``` ## Viewing retry queue @@ -129,7 +126,7 @@ sqlite3 state.db "SELECT filename, status, retry_count, datetime(next_retry, 'un ## Moving to a new server -1. Copy the project directory (including `.env` and `state.db`) +1. Copy the project directory to `~/matrix-paperless-ingest` (including `.env` and `state.db`) 2. Install `uv`, `libolm3`, and `python3-olm` on the new server 3. Run `uv venv --system-site-packages && uv sync --no-install-package python-olm` -4. Install the systemd service as above +4. Install the systemd user service as above diff --git a/paperless-ingest.service b/matrix-paperless-ingest.service similarity index 53% rename from paperless-ingest.service rename to matrix-paperless-ingest.service index 549bc28..8b461db 100644 --- a/paperless-ingest.service +++ b/matrix-paperless-ingest.service @@ -5,14 +5,13 @@ Wants=network-online.target [Service] Type=simple -User=matrix-paperless-ingest -WorkingDirectory=/opt/matrix-paperless-ingest -EnvironmentFile=/opt/matrix-paperless-ingest/.env -ExecStart=uv run --no-sync python ingest.py +WorkingDirectory=%h/matrix-paperless-ingest +EnvironmentFile=%h/matrix-paperless-ingest/.env +ExecStart=%h/.local/bin/uv run --no-sync python ingest.py Restart=on-failure RestartSec=10 StandardOutput=journal StandardError=journal [Install] -WantedBy=multi-user.target +WantedBy=default.target