From 19d54e9cf0e60828049ca552d20a048dfac46671 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Wed, 11 Nov 2026 23:55:03 -0700 Subject: [PATCH] Add upgrade --check: report what can be upgraded, change nothing inbuxa upgrade --check prints the same what-is-here against what-this- installer-installs table as a dry run, then stops with an exit code a script or cron job can act on: 10 when a component can be upgraded, 0 when none can. It changes nothing, so it needs neither --yes nor root. This replaces hand-tracking the pinned releases with a command that says when the installed suite is behind the one this installer ships. --- cmd/inbuxa/main.go | 11 ++++++++++- cmd/inbuxa/main_test.go | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/inbuxa/main.go b/cmd/inbuxa/main.go index e73fb26..18b845e 100644 --- a/cmd/inbuxa/main.go +++ b/cmd/inbuxa/main.go @@ -54,7 +54,8 @@ const usage = `inbuxa -- install the inbuxa suite on this machine inbuxa status what is installed here, and whether it agrees inbuxa upgrade [component…] move what is here to the releases this installer installs: --dry-run, --yes, - --no-backup + --no-backup, --check (report only; exit 10 if + anything can be upgraded) inbuxa uninstall take the programs away, keep the data: --dry-run, --yes, --purge (the data too) inbuxa certs [--key KEY] the mail server's certificate: what its mail @@ -777,6 +778,7 @@ func upgradeCmd(args []string) int { dryRun := fs.Bool("dry-run", false, "") yes := fs.Bool("yes", false, "") noBackup := fs.Bool("no-backup", false, "") + check := fs.Bool("check", false, "") // Components and options in any order: `upgrade server --yes` as well as // `upgrade --yes server`. The flag package stops at the first argument // that isn't an option, so parse again after each one. @@ -829,6 +831,13 @@ func upgradeCmd(args []string) int { fmt.Println("\nNothing to do: this is what this installer installs. A newer installer brings newer releases.") return 0 } + // --check reports and stops, with an exit code a script or a cron job can + // act on: 10 when something can be upgraded, 0 when nothing can. It never + // changes anything, so it needs neither --yes nor root. + if *check { + fmt.Printf("\n%d component(s) can be upgraded. Run `inbuxa upgrade` to apply.\n", due) + return 10 + } backup := !*noBackup for _, s := range steps { if s.Component == plan.Server && s.Due() { diff --git a/cmd/inbuxa/main_test.go b/cmd/inbuxa/main_test.go index c29f86b..d16df8c 100644 --- a/cmd/inbuxa/main_test.go +++ b/cmd/inbuxa/main_test.go @@ -20,6 +20,8 @@ func TestUpgradeTakesOptionsAfterComponents(t *testing.T) { {"server", "--no-backup", "--dry-run"}, {"--dry-run", "server", "console"}, {"webmail", "--dry-run", "--no-backup"}, + {"--check"}, + {"server", "--check"}, } { if code := upgradeCmd(args); code == 2 { t.Errorf("upgrade %v: taken as a usage error", args) -- 2.54.0