Move scripts: stop by project, so a pulled clone works #8

Merged
thodkatz merged 7 commits from change/move-scripts-pulled into main 2026-11-05 12:22:06 +00:00
Owner

Change. move-vps.sh stopped at step 2 on the VPS: ERROR: could not find root of overleaf-toolkit project. The clone was already at 3ea4c1b (pulled to get the script), while every stack still ran from the old top-level directories. Nothing was stopped or moved. Both scripts assumed the clone wasn't pulled yet: after the pull the old compose files are gone, so the stop-by-file loop skipped every stack, and overleaf's untracked bin/docker-compose ran without the config/ the pull had moved.

What changes

  • docs/guides/move-vps.sh
    • Step 2 stops each compose project read from the labels of the containers running from the clone's old directories: docker compose -p <project> down, run from /, with no file and no -v. This works whether or not the clone is pulled, and covers overleaf and mywebsite (project mysite). It first probes that docker compose -p … ps works without a file, and stops if it doesn't.
    • Before stopping anything, it records which stacks run (/root/move-vps-running-before, written once, <stack> <project>). Step 5 starts only those, in the same order, and lists the ones it leaves stopped (today: actual, grafana, stirling-pdf, uptime-kuma, wallos, wud). mywebsite starts with docker compose -p <its project> up -d when it has a compose file; otherwise the user is told to start it. If nothing runs from the clone, it stops, because step 5 wouldn't know what to start.
    • The ente ente_postgres-data mount check moves before the stop. The separate -f old-compose.yaml down is dropped, since the project stop covers it. old-compose.yaml and the copy are as before.
  • docs/guides/move-nixos.sh: after the file loop, whatever still runs from the old directories is stopped by project if podman compose -p … ps works from /. Otherwise the script stops before stopping anything and says to stop those projects by hand.
  • The guide's The scripts section says a pulled clone works, and that the manual steps assume it isn't pulled.

Check. Run against scratch clones with stateful stubs of docker/podman/id/sudo/curl (the stub's ps reports containers in the old dirs; compose -p X down removes them; up adds them under the new dir):

  • VPS, clone already at origin/main: --dry-run changes nothing. The full run stops all 11 projects from /, copies ente, leaves no untracked state outside vps/ except the old ente/ (kept on purpose), starts the 8 recorded stacks, overleaf (bin/up), ente's copy and mysite in vps/mywebsite, and lists the 6 it left stopped. A re-run stops nothing and starts the same set.
  • VPS, clone at 3f0e6da (not pulled): it pulls to origin/main, moves the state and starts what ran.
  • VPS: a failing probe, and no containers at all, each print STOPPED before stopping anything.
  • NixOS host, pulled clone: a failing probe stops before stopping anything. With the probe working, all 4 projects are stopped from / and the state moves. Step 5 then stops at nixos/plane/compose.sh's own "not the NixOS host" guard; this PR doesn't change it.
  • shellcheck -e SC2015 is clean on both scripts.

After the merge: on the VPS, cd /srv/selfhosted && git pull, then git show origin/main:docs/guides/move-vps.sh > /root/move-vps.sh, bash /root/move-vps.sh --dry-run and bash /root/move-vps.sh. Nothing to deploy otherwise.

Rules this PR removes or rewrites:

  • The guide's "the script is fetched before the pull" becomes "fetched from origin/main, which works whether or not the clone is pulled". The guide also gains "the manual steps assume the clone isn't pulled".
  • move-vps.sh step 5 used to start every stack; it now starts only the ones that ran before and lists the rest. move-nixos.sh still starts all four.
  • move-vps.sh used to stop each stack by its old compose file, overleaf with bin/docker-compose down and the old ente with -f old-compose.yaml down. It now stops each project, and stops before stopping anything when a stack it doesn't know runs from the clone.
  • "Is mywebsite stopped?" is asked only when no container runs from mywebsite/. "Start vps/mywebsite the way you run it" is printed only when the script didn't start it.

🤖 Generated with Claude Code

> **Change.** `move-vps.sh` stopped at step 2 on the VPS: `ERROR: could not find root of overleaf-toolkit project`. The clone was already at `3ea4c1b` (pulled to get the script), while every stack still ran from the old top-level directories. Nothing was stopped or moved. Both scripts assumed the clone wasn't pulled yet: after the pull the old compose files are gone, so the stop-by-file loop skipped every stack, and overleaf's untracked `bin/docker-compose` ran without the `config/` the pull had moved. **What changes** - `docs/guides/move-vps.sh` - Step 2 stops each **compose project** read from the labels of the containers running from the clone's old directories: `docker compose -p <project> down`, run from `/`, with no file and no `-v`. This works whether or not the clone is pulled, and covers overleaf and mywebsite (project `mysite`). It first probes that `docker compose -p … ps` works without a file, and stops if it doesn't. - Before stopping anything, it records which stacks run (`/root/move-vps-running-before`, written once, `<stack> <project>`). Step 5 starts only those, in the same order, and lists the ones it leaves stopped (today: actual, grafana, stirling-pdf, uptime-kuma, wallos, wud). mywebsite starts with `docker compose -p <its project> up -d` when it has a compose file; otherwise the user is told to start it. If nothing runs from the clone, it stops, because step 5 wouldn't know what to start. - The ente `ente_postgres-data` mount check moves before the stop. The separate `-f old-compose.yaml down` is dropped, since the project stop covers it. `old-compose.yaml` and the copy are as before. - `docs/guides/move-nixos.sh`: after the file loop, whatever still runs from the old directories is stopped by project if `podman compose -p … ps` works from `/`. Otherwise the script stops before stopping anything and says to stop those projects by hand. - The guide's *The scripts* section says a pulled clone works, and that the manual steps assume it isn't pulled. **Check.** Run against scratch clones with stateful stubs of `docker`/`podman`/`id`/`sudo`/`curl` (the stub's `ps` reports containers in the old dirs; `compose -p X down` removes them; `up` adds them under the new dir): - VPS, clone already at `origin/main`: `--dry-run` changes nothing. The full run stops all 11 projects from `/`, copies ente, leaves no untracked state outside `vps/` except the old `ente/` (kept on purpose), starts the 8 recorded stacks, overleaf (`bin/up`), ente's copy and `mysite` in `vps/mywebsite`, and lists the 6 it left stopped. A re-run stops nothing and starts the same set. - VPS, clone at `3f0e6da` (not pulled): it pulls to `origin/main`, moves the state and starts what ran. - VPS: a failing probe, and no containers at all, each print `STOPPED` before stopping anything. - NixOS host, pulled clone: a failing probe stops before stopping anything. With the probe working, all 4 projects are stopped from `/` and the state moves. Step 5 then stops at `nixos/plane/compose.sh`'s own "not the NixOS host" guard; this PR doesn't change it. - `shellcheck -e SC2015` is clean on both scripts. **After the merge:** on the VPS, `cd /srv/selfhosted && git pull`, then `git show origin/main:docs/guides/move-vps.sh > /root/move-vps.sh`, `bash /root/move-vps.sh --dry-run` and `bash /root/move-vps.sh`. Nothing to deploy otherwise. **Rules this PR removes or rewrites:** - The guide's "the script is fetched before the pull" becomes "fetched from `origin/main`, which works whether or not the clone is pulled". The guide also gains "the manual steps assume the clone isn't pulled". - `move-vps.sh` step 5 used to start every stack; it now starts only the ones that ran before and lists the rest. `move-nixos.sh` still starts all four. - `move-vps.sh` used to stop each stack by its old compose file, overleaf with `bin/docker-compose down` and the old ente with `-f old-compose.yaml down`. It now stops each project, and stops before stopping anything when a stack it doesn't know runs from the clone. - "Is mywebsite stopped?" is asked only when no container runs from `mywebsite/`. "Start vps/mywebsite the way you run it" is printed only when the script didn't start it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: theo <thodkatz@pm.me>
The user's VPS run stopped at step 2 with every service still up: the clone was
pulled before the script ran, so the old compose files were gone and overleaf's
toolkit lacked its moved config/. The fix is designed here, not built yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The user pulled the VPS clone to get the script, and step 2 stopped at
overleaf: after the pull the old compose files are gone, so the
stop-by-file loop skipped every stack and the toolkit's bin/docker-compose
ran without its config/. Stopping each project found on the running
containers' labels works pulled or not, and covers overleaf and
mywebsite (project mysite) without special cases.

Step 5 now starts only the stacks that ran before (recorded once, in
move-vps-running-before), so a stack that was off stays off, and
mywebsite starts under its own project when it has a compose file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The same gap as on the VPS: a pulled clone has no compose files in the
old directories, so the stop-by-file loop skips everything. What still
runs from them is stopped by compose project, if podman compose can stop
one without a file (probed from /); otherwise the script stops before
stopping anything and says to stop them by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The user pulled the VPS clone before running move-vps.sh, which the
guide's 'fetched before the pull' wording didn't rule out. Say that the
scripts handle it now, and that the manual steps still assume the clone
isn't pulled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
move-vps.sh stops before stopping anything when a stack it doesn't know
runs from the clone (it would have stopped it and never started it
again), warns when ente ran but has no copy to start, checks for ente's
volume before the stop rather than after it, keeps the record of what
ran in memory until the user confirms the stop (so a dry run or an N
leaves nothing behind), and its header no longer says it starts
everything. move-nixos.sh probes podman compose in a dry run too, so the
dry run stops where the real one would. The guide no longer says the
NixOS script restarts only what ran, and names the NixOS fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Author
Owner

Local review round (two reviewer subagents: correctness, methodology).

Correctness (verdict: with fixes):

  1. Important, move-vps.sh step 2/5: a project under the clone that the script doesn't know (a retired stack still running, e.g. seafile) is stopped and then neither started nor reported.
  2. Minor: if ente ran but there is no copy, ente is neither started nor listed.
  3. Minor: the ente_postgres-data volume check runs after step 2 has stopped everything.
  4. Minor: mktemp leaves a file on every first run, dry or real.
  5. Minor, move-nixos.sh: the dry run skips the podman probe, so it passes where the real run would stop.
  6. Minor: the running-before record is written before the confirmation, so a run answered N leaves a stale record.

Methodology (verdict: fix 7 and 8, then merge):
7. Important, guide The scripts: "start again only the stacks that ran before" is wrong for move-nixos.sh, which starts all four.
8. Important, PR body: Rules this PR removes or rewrites is incomplete.
9. Minor: move-vps.sh's header still says "starts everything again".
10. Minor, guide: "stop each compose project" holds on NixOS only if podman compose can stop one without its file.
11. Minor, guide: "or read from the clone" gives no command.
12. Minor: no closing handoff yet.

Checks: the repo's Setup check command: exit 0. shellcheck -e SC2015 docs/guides/move-*.sh: exit 0. python3 .methodology/shared/sync-agents.py --check: exit 0.

**Local review round** (two reviewer subagents: correctness, methodology). Correctness (verdict: with fixes): 1. Important, `move-vps.sh` step 2/5: a project under the clone that the script doesn't know (a retired stack still running, e.g. seafile) is stopped and then neither started nor reported. 2. Minor: if ente ran but there is no copy, ente is neither started nor listed. 3. Minor: the `ente_postgres-data` volume check runs after step 2 has stopped everything. 4. Minor: `mktemp` leaves a file on every first run, dry or real. 5. Minor, `move-nixos.sh`: the dry run skips the podman probe, so it passes where the real run would stop. 6. Minor: the running-before record is written before the confirmation, so a run answered N leaves a stale record. Methodology (verdict: fix 7 and 8, then merge): 7. Important, guide *The scripts*: "start again only the stacks that ran before" is wrong for `move-nixos.sh`, which starts all four. 8. Important, PR body: *Rules this PR removes or rewrites* is incomplete. 9. Minor: `move-vps.sh`'s header still says "starts everything again". 10. Minor, guide: "stop each compose project" holds on NixOS only if podman compose can stop one without its file. 11. Minor, guide: "or read from the clone" gives no command. 12. Minor: no closing handoff yet. Checks: the repo's *Setup* check command: exit 0. `shellcheck -e SC2015 docs/guides/move-*.sh`: exit 0. `python3 .methodology/shared/sync-agents.py --check`: exit 0.
Author
Owner

Replies to the review round, all in 7f89151 unless noted:

  1. Fixed: step 1 stops (before stopping anything) when a stack outside the script's list runs from the clone. Tested with a seafile project.
  2. Fixed: a WARNING when ente ran but has no copy to start.
  3. Fixed: the volume check moved into step 1, beside the mount check.
  4. Fixed: the list is kept in a variable; no temp file.
  5. Fixed: the probe runs in a dry run too (it is read-only). Tested: the dry run now stops like the real one.
  6. Fixed: the record is written just after the step 2 confirmation. Tested: an N leaves no record.
  7. Fixed: the guide says the VPS script restarts only what ran and the NixOS script starts all four.
  8. Fixed in the PR body.
  9. Fixed: the header now says "starts again what ran before".
  10. Fixed: the guide names the NixOS fallback.
  11. Fixed: the guide now says git show origin/main: works whether or not the clone is pulled.
  12. Comes with the merge: a handoff on this branch, then the post-merge one on main.
Replies to the review round, all in `7f89151` unless noted: 1. Fixed: step 1 stops (before stopping anything) when a stack outside the script's list runs from the clone. Tested with a `seafile` project. 2. Fixed: a `WARNING` when ente ran but has no copy to start. 3. Fixed: the volume check moved into step 1, beside the mount check. 4. Fixed: the list is kept in a variable; no temp file. 5. Fixed: the probe runs in a dry run too (it is read-only). Tested: the dry run now stops like the real one. 6. Fixed: the record is written just after the step 2 confirmation. Tested: an N leaves no record. 7. Fixed: the guide says the VPS script restarts only what ran and the NixOS script starts all four. 8. Fixed in the PR body. 9. Fixed: the header now says "starts again what ran before". 10. Fixed: the guide names the NixOS fallback. 11. Fixed: the guide now says `git show origin/main:` works whether or not the clone is pulled. 12. Comes with the merge: a handoff on this branch, then the post-merge one on `main`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
thodkatz changed title from WIP: Move scripts: stop by project, so a pulled clone works to Move scripts: stop by project, so a pulled clone works 2026-11-05 12:22:01 +00:00
thodkatz deleted branch change/move-scripts-pulled 2026-11-05 12:22:06 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thodkatz/selfhosted!8
No description provided.