Let a host with no internet supply the migration script itself

`run` and `rehearse` always fetched migrate_v016.py from GitHub, so a mail
server with no route out could not be migrated at all - an air-gapped host,
or a clone deliberately cut off so it cannot renew certificates or deliver
queued mail for the domains it was copied from. --migration-script takes a
local copy instead, still checked against --migration-script-sha256 when one
is pinned.

Found while staging a production clone for a dress rehearsal: the clone has
no route out on purpose, and that is exactly the property that stops a copy
of a live mail server doing something in the real world.
This commit is contained in:
2026-08-24 15:12:35 -07:00
parent 3adaee3bc6
commit 0739866c14
4 changed files with 84 additions and 2 deletions
+2 -1
View File
@@ -55,6 +55,7 @@ func runRehearse(args []string) (err error) {
stalwartCLI := fs.String("stalwart-cli", "stalwart-cli",
"path to stalwart-cli (v1.0.2 or later; a separate download from the server) - rehearsal doesn't invoke it, but checks it so `run` doesn't fail after stopping the service")
migrationScriptSHA256 := fs.String("migration-script-sha256", "", "pinned sha256 of migrate_v016.py (recommended; the first run prints the hash to pin)")
migrationScriptPath := fs.String("migration-script", "", "use a local copy of migrate_v016.py instead of fetching it (for a host with no route to the internet)")
minFree := fs.Float64("min-free-multiple", 2.0, "free-space multiple preflight checks for; rehearsal itself copies nothing")
keepArtifacts := fs.Bool("keep-artifacts", false, "don't delete work-dir/<run-id> afterward")
if err := fs.Parse(args); err != nil {
@@ -146,7 +147,7 @@ func runRehearse(args []string) (err error) {
if err := os.MkdirAll(runWorkDir, 0o750); err != nil {
return checkpoint.StepOutcome{}, err
}
sum, err := backup.DownloadFile(ctx, httpClient, backup.DefaultMigrationScriptURL, scriptDest, *migrationScriptSHA256)
sum, err := backup.ProvideFile(ctx, httpClient, *migrationScriptPath, backup.DefaultMigrationScriptURL, scriptDest, *migrationScriptSHA256)
if err != nil {
return checkpoint.StepOutcome{}, err
}