Skip to content

feat: unified CLI installer and operations manager (./install.sh) - #75

Merged
TrezorHannes merged 4 commits into
mainfrom
feat/unified-installer
Nov 26, 2026
Merged

TrezorHannes merged 4 commits into
mainfrom
feat/unified-installer

Conversation

@TrezorHannes

Copy link
Copy Markdown
Owner

Summary of Changes

PR 2 of the phased Lightning-Python-Tools optimization plan — replaces the two standalone shell installers with a unified, pure-stdlib installer and operations manager (./install.sh + lpt_installer/):

  • Unified Entrypoint & Registry (./install.sh, lpt_installer/):
    • install.sh: non-root guard, Python 3.11–3.13 detection, delegates to python3 -m lpt_installer.
    • lpt_installer/registry.py: single-source-of-truth ToolSpec registry for all 19 scripts (risk tier, host profile node/vps, supported scheduling modes, unattended args, required configs, legacy units).
  • Environment, Configs, Scheduling & Safety:
    • lpt_installer/env.py: unified .venv setup (uv fast-path with stdlib venv fallback, optional db extra for offline_summary.py) + doctor diagnostics (Python, certifi, OS CA bundle, 0o600 config perms, root-owned runtime files, legacy units).
    • lpt_installer/configs.py: non-clobbering copy from *.example, chmod 600 on configs (chmod 700 on logs//data/), $VISUAL/$EDITOR launch, and placeholder/schema validation.
    • lpt_installer/scheduler.py: hardened lpt-* systemd services/timers (SSL_CERT_FILE, REQUESTS_CA_BUNDLE, TimeoutStartSec=300, ProtectSystem=full/strict, explicit PATH) and idempotent managed-block cron (flock -n), fail-closed unmanaged duplicate detector, .lpt-backups/ pre-change snapshots, automatic migration of legacy pocketmoney.*/fee_adjuster.*/etc., and clean uninstall preserving user configs by default.
    • lpt_installer/cli.py: interactive numbered menu with overview table + scriptable subcommands (list, status, env, config, install, uninstall, doctor), MIT/self-verify disclaimer acknowledgment, [FUNDS] banner, and https://hodlmetight.org footer.
  • Cleanup, Tests & CI:
    • Removed legacy LNBits/install_pocketmoney_service.sh and Other/install_fee_adjuster_service.sh and updated direct references.
    • Extended tests/test_ca_trust_hardening.py to verify all generated systemd units and cron blocks, added tests/test_lpt_installer.py (87.90% coverage on lpt_installer), and added systemd-analyze verify + >=85% lpt_installer coverage gate in .github/workflows/tests.yml.

Verification

  • .venv/bin/pytest tests/ -v --cov=... --cov-fail-under=35: 222 passed (47.73% total coverage).
  • .venv/bin/pytest tests/test_lpt_installer.py tests/test_ca_trust_hardening.py --cov=lpt_installer --cov-fail-under=85: 14 passed (87.90% coverage).
  • bash -n install.sh, ./install.sh list, .venv/bin/python -m pip_audit: all passed.
  • Note: Greptile is not enabled / unavailable locally (greptile-guard), so this PR is verified via GitHub Actions CI + TunnelSentinel.

- Add thin root bootstrapper ./install.sh (non-root guard, Python 3.11-3.13 detection) and pure-stdlib lpt_installer package.
- Registry covers all 19 scripts with risk tiers, host profiles (node/vps), supported execution modes, config requirements, and legacy unit metadata.
- Supports uv fast-path + stdlib venv fallback, OS CA trust bundle bindings (SSL_CERT_FILE/REQUESTS_CA_BUNDLE) across all systemd units and cron blocks, systemd sandboxing (ProtectSystem=full / strict for HTTP-only pocketmoney), TimeoutStartSec=300, and flock-guarded cron blocks.
- Adds fail-closed unmanaged duplicate detection, .lpt-backups/ snapshots, legacy unit migration, guided chmod 600 config copy + placeholder validation, clean uninstall preserving configs by default, MIT/self-verify disclaimer, and subtle hodlmetight.org footer.
- Remove legacy LNBits/install_pocketmoney_service.sh and Other/install_fee_adjuster_service.sh; update tests/test_ca_trust_hardening.py, add tests/test_lpt_installer.py (87.90% coverage on lpt_installer), and add systemd-analyze verify + 85% coverage gates in CI.
@TrezorHannes TrezorHannes added documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code labels Nov 26, 2026
@TrezorHannes TrezorHannes self-assigned this Nov 26, 2026

@tunnelsentinel tunnelsentinel Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TunnelSentinel: 6 new findings on commit `261a894`, inline below. The TunnelSentinel summary comment on this pull request has the full review.

Comment thread lpt_installer/configs.py Resolved
Comment thread lpt_installer/adapters.py Resolved
Comment thread lpt_installer/scheduler.py Resolved
Comment thread lpt_installer/scheduler.py Resolved
Comment thread lpt_installer/scheduler.py Resolved
Comment thread lpt_installer/cli.py Resolved
@tunnelsentinel

tunnelsentinel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🛡️⚡ TunnelSentinel Code Review

Verdict: COMMENT (LGTM. High-Risk Tier: a maintainer merges) | Confidence: 5/5 | Risk Tier: HIGH
"Zero leaks. Fail-closed verification."


Latest commit: ea4f510 | Status: success | Reviewed: 2026-11-26 21:48 UTC

Targeted Re-Review Summary (Commit ea4f510)

All 6 prior findings (P1/P2/P3) have been verified fixed on head commit ea4f510b5d97ebf8c070f0d518eaf77fa5b39dd2 and all 6 review threads have been resolved:

  • [P1] lpt_installer/configs.py (PRRT_kwDOLIiRiM68kYBP): Verified validate_configs() now checks that wallet_id and invoice_key are non-empty strings and rejects WALLETID*, INVOICEID* (matching wallets.json.example), and INVOICEKEY* placeholders.
  • [P1] lpt_installer/adapters.py (PRRT_kwDOLIiRiM68kYBZ): Verified SystemEnv.read_crontab() and SystemEnv.write_crontab() guard against a missing crontab binary via self.which("crontab") is None (returning "" on read, succeeding as no-op on empty write, and raising an explicit RuntimeError on non-empty write), while install_tool() skips unnecessary write_crontab() calls on systemd installs when no managed cron entry exists.
  • [P1] lpt_installer/scheduler.py:154 (PRRT_kwDOLIiRiM68kYBc): Verified render_systemd_service() only appends tool.unattended_args when chosen_mode == "systemd-timer", so pocketmoney in systemd-service mode runs as a daemon without --run-once.
  • [P2] lpt_installer/scheduler.py:424 (PRRT_kwDOLIiRiM68kYBh): Verified detect_conflicts() hoists MainPID lookup for lpt-<id>.service before scanning running_processes() and excludes only proc_pid == managed_pid (still failing closed on extra unmanaged PIDs), and install_tool() executes systemctl try-restart after enable --now on systemd-service updates.
  • [P2] lpt_installer/scheduler.py:308 (PRRT_kwDOLIiRiM68kYBr): Verified render_cron_entry() places the flock lock file inside the 0700 repo_root/logs/.lpt-<id>.lock directory instead of shared /tmp.
  • [P3] lpt_installer/cli.py (PRRT_kwDOLIiRiM68kYBy): Verified config, install, and uninstall catch KeyError from get_tool() and exit cleanly with code 1.

Empirical Verification

  • .venv/bin/pytest tests/ -v --cov=LNDg --cov=Magma --cov=Other --cov=Peerswap --cov=LNBits --cov=lpt_installer --cov-report=term --cov-fail-under=35: 223 passed, total coverage 48.66%.
  • .venv/bin/pytest tests/test_lpt_installer.py tests/test_ca_trust_hardening.py --cov=lpt_installer --cov-report=term --cov-fail-under=85: 15 passed, lpt_installer coverage 88.80%.

Verdict

  • Risk Tier: HIGH
  • Confidence: 5/5 — Zero remaining P0/P1/P2/P3 issues. LGTM. High-Risk Tier: a maintainer merges.

Review history

  • ea4f510: COMMENT (LGTM. High-Risk Tier: a maintainer merges), 5/5, HIGH risk, status success, 2026-11-26 21:48 UTC
  • 261a894: REQUEST_CHANGES, 3/5, HIGH risk, status failure, 6 inline findings, 2026-11-26 21:44 UTC

- lpt_installer/configs.py: reject INVOICEID*, INVOICEKEY*, empty, and non-string values for wallets.json wallet_id/invoice_key.
- lpt_installer/adapters.py: degrade gracefully when crontab binary is missing (return empty crontab on read, succeed on empty write, clear error on non-empty cron write).
- lpt_installer/scheduler.py: only pass tool.unattended_args (--run-once) in systemd-timer mode (not systemd-service daemon mode), move cron flock lock file from /tmp into 0700 repo logs/, ignore managed MainPID when re-installing an active lpt-* daemon, and run systemctl try-restart after service unit updates.
- lpt_installer/cli.py: catch KeyError for unknown tool IDs across config, install, and uninstall subcommands.
- tests/test_lpt_installer.py: add regression tests for all 6 findings (223/223 passing, 88.80% lpt_installer coverage).
@tunnelsentinel
tunnelsentinel Bot dismissed their stale review November 26, 2026 21:48

Superseded by a clean TunnelSentinel review of commit ea4f510, the current head of this pull request.

@TrezorHannes
TrezorHannes merged commit 7aecab5 into main Nov 26, 2026
12 checks passed
@TrezorHannes
TrezorHannes deleted the feat/unified-installer branch November 26, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant