24d062fc5d
Replace stub notify() with full Synapse integration targeting General room. - Add _send_matrix(), _get_matrix_token(), _matrix_login() helpers - Implement token cache with 30-min refresh threshold and 401 retry - Fetch credentials via Infisical (MATRIX_USER, MATRIX_PASSWORD from matrix/) - Add MATRIX_* env overrides for testing (homeserver, room, token cache path) - Non-fatal failures: Matrix outage logs warning, does not break mirror run - Add 5 comprehensive test cases covering success, failure, 401 refresh, env override, chmod 600 - All 18 tests passing - Update README and notes.md with implementation details
73 lines
2.6 KiB
Markdown
73 lines
2.6 KiB
Markdown
# coe-mirror
|
||
|
||
Mirror Nightmare_Eclipse repos from Church of Malware to pCloud.
|
||
|
||
## What it does
|
||
|
||
Monitors `Nightmare_Eclipse` on `git.churchofmalware.org` for new or updated repos. Downloads per-commit zip snapshots to `~/pCloudDrive/Hacking/Nightmare_Eclipse/`. Falls back to local staging when pCloud is down. Runs at 00:00 and 12:00 daily with boot catch-up.
|
||
|
||
## Filename convention
|
||
|
||
`{repo}_{short_sha}.zip` where short_sha is the first 8 chars of the HEAD commit SHA on the default branch. New commits produce new files; old snapshots stay as history.
|
||
|
||
## Install
|
||
|
||
```
|
||
cd ~/tools/coe-mirror
|
||
bash install.sh
|
||
```
|
||
|
||
## Manual run
|
||
|
||
```
|
||
systemctl --user start coe-mirror.service
|
||
# or directly:
|
||
python3 ~/tools/coe-mirror/coe_mirror.py
|
||
```
|
||
|
||
## Logs
|
||
|
||
- File: `~/.local/share/coe-mirror/coe-mirror.log` (rotated at 5 MB, 3 backups)
|
||
- Journal: `journalctl --user -u coe-mirror.service -n 100`
|
||
|
||
## Storage estimate
|
||
|
||
8 repos × 2 runs/day × ~1 commit/repo/day ≈ 16 zips/day ≈ ~5 MB/month at current zip sizes (~265 KB each). Old snapshots accumulate — no automatic pruning. Manually prune `~/pCloudDrive/Hacking/Nightmare_Eclipse/` if needed.
|
||
|
||
## Behavior when pCloud is down
|
||
|
||
Downloads land in `~/.local/share/coe-mirror/pending/`. Next run (or any subsequent invocation) flushes them to pCloud once the mount is healthy. No auto-start of the pCloud daemon — by design, because the daemon is a GUI AppImage with no systemd user unit. If pCloud is offline, ensure the user session is active and pCloud is running before the next scheduled run, or trigger manually.
|
||
|
||
## Catch-up after machine was off
|
||
|
||
The timer is `Persistent=true` and `OnBootSec=2min`. Missed windows run automatically on next boot. The tool also diffs against the pCloud directory, so even if a run is skipped entirely, the next run catches up everything that's missing.
|
||
|
||
## Matrix notification
|
||
|
||
After every run that lands at least one new zip, coe-mirror posts a summary
|
||
to the General room (`!REDACTEDROOM:m.example.org`) on
|
||
`m.example.org`.
|
||
|
||
- Authentication uses `MATRIX_USER` + `MATRIX_PASSWORD` from Infisical folder
|
||
`matrix`. Tokens are cached at `~/.local/share/coe-mirror/matrix-token.json`
|
||
(mode 0600) and auto-refreshed on expiry or 401.
|
||
- Failures are non-fatal: a Matrix outage logs a warning and the rest of the
|
||
run proceeds normally.
|
||
- Override the target room for testing: `COE_MIRROR_MATRIX_ROOM=! ...:host`.
|
||
- Override the homeserver: `COE_MIRROR_MATRIX_HOMESERVER=https://...`.
|
||
|
||
## Testing
|
||
|
||
```
|
||
cd ~/tools/coe-mirror
|
||
python3 -m pytest tests/ -v
|
||
```
|
||
|
||
## Uninstall
|
||
|
||
```
|
||
systemctl --user disable --now coe-mirror.timer
|
||
rm ~/.config/systemd/user/coe-mirror.{service,timer}
|
||
systemctl --user daemon-reload
|
||
```
|