Skip to content

fix(vpn): use OPERATOR_USERNAME for headless Plex token/notification#71

Merged
smartwatermelon merged 1 commit intomainfrom
claude/fix-plex-vpn-bypass-headless-console-2026-02-23
Feb 23, 2026
Merged

fix(vpn): use OPERATOR_USERNAME for headless Plex token/notification#71
smartwatermelon merged 1 commit intomainfrom
claude/fix-plex-vpn-bypass-headless-console-2026-02-23

Conversation

@smartwatermelon
Copy link
Copy Markdown
Owner

Summary

  • Replaces stat -f%Su /dev/console console-user detection in plex-vpn-bypass.sh with the deploy-time __OPERATOR_USERNAME__ template variable
  • On a headless server with no active GUI session, stat returns (NNN) (UID in parens) — neither empty nor "root" — so the old guard passed but the username was garbage, causing token lookup to fail and customConnections to go stale
  • Adds sed substitution for __OPERATOR_USERNAME__ in transmission-setup.sh so future deployments work correctly

Files changed

File Change
app-setup/templates/plex-vpn-bypass.sh Add OPERATOR_USERNAME config var; remove console_user detection from notify() and get_plex_token()
app-setup/transmission-setup.sh Add sed substitution for __OPERATOR_USERNAME__ at deploy time
docs/vpn-transmission.md Document new template placeholder

Live fix on TILSIT

The patched script is already uploaded to /tmp/plex-vpn-bypass-fixed.sh on TILSIT. To activate:

ssh operator@tilsit.local
sudo cp /tmp/plex-vpn-bypass-fixed.sh /usr/local/bin/plex-vpn-bypass.sh
sudo chmod 755 /usr/local/bin/plex-vpn-bypass.sh
sudo launchctl kickstart -k system/com.tilsit.plex-vpn-bypass
tail -f /var/log/tilsit-plex-vpn-bypass.log

The daemon will update customConnections to the current public IP within 60 seconds.

Test Plan

  • shellcheck app-setup/templates/plex-vpn-bypass.sh — clean
  • shellcheck app-setup/transmission-setup.sh — clean
  • Live: apply patch on TILSIT, confirm log shows successful customConnections update to current IP (67.5.106.16)

🤖 Generated with Claude Code

Replaces `stat -f%Su /dev/console` console-user detection with the
deploy-time template variable `__OPERATOR_USERNAME__`. On headless
servers, `stat` returns `(NNN)` (UID in parens) when no GUI session
is active, which is neither empty nor "root" — so the old guard passed
but the username was garbage. Token lookup failed → customConnections
stayed stale.

Changes:
- plex-vpn-bypass.sh template: add OPERATOR_USERNAME config var, remove
  console_user detection from notify() and get_plex_token()
- transmission-setup.sh: add sed substitution for __OPERATOR_USERNAME__
- docs/vpn-transmission.md: document the new template placeholder

Live patch uploaded to /tmp/plex-vpn-bypass-fixed.sh on TILSIT for
manual apply (see PR for apply instructions).

AI review: code-reviewer (1 iteration)
Adversarial review: code-critic:adversarial-reviewer (1 iteration)
Issues fixed: none additional

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@smartwatermelon smartwatermelon merged commit 40d5b2c into main Feb 23, 2026
17 checks passed
@smartwatermelon smartwatermelon deleted the claude/fix-plex-vpn-bypass-headless-console-2026-02-23 branch February 23, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant