Skip to content

refactor: split sync-runtime.sh into deploy/lib modules (#21) - #32

Merged
ROBJkE merged 1 commit into
mainfrom
cursor/split-sync-runtime-libs-91a0
Sep 13, 2026
Merged

ROBJkE merged 1 commit into
mainfrom
cursor/split-sync-runtime-libs-91a0

Conversation

@ROBJkE

@ROBJkE ROBJkE commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Split the kitchen-sink deploy/sync-runtime.sh into a thin CLI dispatcher plus small sourced libs. Operator commands, flags, deploy/sync.env vars, dump defaults, live refuse, and console rewrite stay the same.

Closes #21 (parent: #12). Host/CD stays bash. Dump remains shopware-cli project dump; restore stays MySQL client. Console is only for fyrst:sales-channel:rewrite-urls.

Module map

deploy/sync-runtime.sh parses args and dispatches snapshot|restore|sync|help. It sources deploy/lib/sync.sh, which loads:

Lib Role
identity.sh SoT path formulas (SHOPWARE_SHOP_ID / env → data root + project name)
compose.sh Compose file list + COMPOSE / COMPOSE_STR
sync-log.sh log / die / CSV / require_cmd
sync-identity.sh Sync-specific derive (SYNC_DATA_ROOT, project-name fallback)
sync-dump.sh Existing dump flags (no duplication)
sync-rewrite.sh Slim guards + compose fyrst:sales-channel:rewrite-urls glue
sync-live.sh Restore refuse + rewrite refuse
sync-ssh.sh Alias env, remote_bash, SSH probe
sync-db.sh shopware-cli dump runners + MySQL client restore
sync-volumes.sh Bind-mount rsync / tar / named-volume fallback
sync-app.sh Stop/start web/worker/scheduler, cache:clear, post-restore hints
sync-commands.sh Bootstrap, lock, snapshot/restore/sync orchestration

Phase 2

  • backup-runtime.sh still calls sync-runtime.sh snapshot (same public path). Identity/compose come from lib/vps-common.sh, which now sources identity.sh / compose.sh.
  • vps-release.sh / vps-rollback.sh are unchanged as scripts; they pick up the shared helpers via vps-common.sh without rewriting rollout logic.

Tests

bash fyrst/shopware-cd/1.0/tests/sync-runtime.test.sh
bash fyrst/shopware-cd/1.0/tests/sync-dump.test.sh
bash fyrst/shopware-cd/1.0/tests/sync-rewrite.test.sh
bash fyrst/shopware-cd/1.0/tests/vps-hardening.test.sh
bash fyrst/shopware-cd/1.0/tests/init-env.test.sh

New checks: SoT path derive, live restore refuse, --data normalize, --help / missing command, staging snapshot --dry-run (mock docker when no daemon). Libs and entrypoints are bash -n / shellcheck clean.

Operator surface

Cron one-liner unchanged:

15 2 * * * cd /opt/shopware/acme-staging && bash deploy/sync-runtime.sh sync --from live --data all

Do not invoke deploy/lib/* from cron. sync-runtime.md notes that helpers live under deploy/lib/.

recipes-contrib

add-fyrst-shopware-cd still exists (symfony/recipes-contrib#2049). This agent could not push the overlay (403 from cursor[bot] on fyrst-dev/recipes-contrib). Mirror from this PR’s deploy/sync-runtime.sh + deploy/lib/ (except vps-common.sh, which that tree does not wire yet).

Open in Web Open in Cursor 

Keep the operator CLI (snapshot|restore|sync flags and sync.env) unchanged.
Move dump, restore, SSH, volumes, live guards, and rewrite glue into
small sourced libs. vps-common now uses the shared identity/compose helpers.

Co-authored-by: ROBJkE <ROBJkE@users.noreply.github.com>
@ROBJkE
ROBJkE marked this pull request as ready for review September 13, 2026 14:43
@ROBJkE
ROBJkE merged commit d6878a0 into main Sep 13, 2026
@ROBJkE
ROBJkE deleted the cursor/split-sync-runtime-libs-91a0 branch September 13, 2026 14:53
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.

[P2] Slim/split sync-runtime.sh and add basic safety tests

2 participants