Repository navigation
Sync paying families' kids onto the whitelist from fullhearts.app - #77
Merged
Merged
Conversation
A timer pulls one realm's wanted list every 2 minutes and adds or removes only players it added itself, tracked in its own ledger. Hand-added players (compose WHITELIST, /whitelist, rcon-cli) are never touched. A bad or paused reply, or a stopped container, changes nothing. Removals go at most 2 per run; more than 5 wanted at once removes nobody and alerts. Installs in dry-run mode; switch SYNC_MODE to apply after checking the reports on the FullHearts admin page. CI now fails if compose ever sets OVERRIDE_WHITELIST, which would rewrite the live whitelist from compose on each deploy and wipe synced players.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
gitops/fullhearts_sync.pykeeps the whitelist in step with paid EduCraft access on fullhearts.app. A systemd timer runs it every 2 minutes. It pulls one realm's list of players who should be on, adds the missing ones and removes the ones it added that should be off, then posts a report back to the FullHearts admin page.gitops/fullhearts_sync.pygitops/fullhearts-sync.service/.timergitops/install_fullhearts_sync.sh/etc/educraft-sync.env(600), enables the timertests/test_fullhearts_sync.py.github/workflows/ci.ymlOVERRIDE_WHITELISTgitops/install_gitops.shWhat it will never do
/var/lib/educraft-sync/ledger.json) and only removes entries in it. SihabMaybe, anything in composeWHITELIST, and anyone added with/whitelist addare left alone.rcon-cliinside the container. No ports, no inbound access. The token can only read one realm's list and post a report.If the ledger is ever lost, everything it added is treated as hand-added and kept, so it fails toward keeping people on.
One trade-off: a player who was whitelisted by hand before paying on the site counts as hand-added, so cancelling won't remove them. You'd remove them yourself.
Install
On the droplet, as root, after merging:
It asks for the sync token. Get it from fullhearts.app/admin, "Set up sync" on the realm.
It starts in dry-run: it only reports what it would do. Watch the reports on the admin page for 3 days. If they look right, set
SYNC_MODE=applyin/etc/educraft-sync.env. The timer picks it up on its next run.Keep
OVERRIDE_WHITELISToff in compose. CI blocks it, because it would rewrite the whitelist on every deploy and wipe the synced kids.Tested
python3 tests/test_fullhearts_sync.pycovers hand-added players, the removal limits, bad replies, hand removals, a name that points to a different account, and the dry-run default.docker: added on payment, removed on cancel, hand-added players untouched, paused / site down / bad token changed nothing.