Show the log in the page over the site while updating or upgrading
The Update page's overlay carries the update's log; the Packages page gets an overlay too, named after the step that runs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,9 +134,19 @@ func (s System) requestUpgrade(action string, force, downgrade bool, timeout str
|
||||
if err := writeFileAtomic(filepath.Join(s.upgradeDir(), "request.json"), data, 0o600); err != nil {
|
||||
return err
|
||||
}
|
||||
// The unit removes the request when it starts; the page says what runs.
|
||||
writeFileAtomic(filepath.Join(s.upgradeDir(), "action"), []byte(action), 0o600)
|
||||
return startUnit("router-upgrade.service")
|
||||
}
|
||||
|
||||
// upgradeTitles say what a running step does, for the page over the site.
|
||||
var upgradeTitles = map[string]string{
|
||||
"check": "Checking for a newer revision…",
|
||||
"preview": "Working out what would change…",
|
||||
"download": "Downloading and building…",
|
||||
"apply": "Upgrading…",
|
||||
}
|
||||
|
||||
type channelChoice struct{ Value, Label string }
|
||||
|
||||
type upgradeData struct {
|
||||
@@ -146,7 +156,8 @@ type upgradeData struct {
|
||||
Check *UpgradeCheck
|
||||
Preview *UpgradePreview
|
||||
Run UpgradeRun
|
||||
Updating bool // router-update is running
|
||||
Title string // what the running step does
|
||||
Updating bool // router-update is running
|
||||
Pending bool // a system waits for confirmation
|
||||
}
|
||||
|
||||
@@ -178,6 +189,12 @@ func (a *app) upgradeData() upgradeData {
|
||||
d.Channel = s.channel()
|
||||
}
|
||||
d.Choices = channelChoices(d.Channel)
|
||||
if d.Run.Running {
|
||||
data, _ := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "action"))
|
||||
if d.Title = upgradeTitles[strings.TrimSpace(string(data))]; d.Title == "" {
|
||||
d.Title = "Working…"
|
||||
}
|
||||
}
|
||||
// What router-upgrade printed: a finished one-shot unit has no journal to find.
|
||||
if data, err := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "last.log")); err == nil {
|
||||
d.Run.Log = tail(string(data), 64<<10)
|
||||
|
||||
Reference in New Issue
Block a user