fix: create boot directory on install and make fixable

- Add boot directory creation to install.go (avoids warning on fresh install)
- Make boot-health check fixable via 'gt doctor --fix'
- Update FixHint to reference the fix command
This commit is contained in:
Dustin Smith
2026-01-19 20:43:41 +07:00
committed by John Ogle
parent 64c6a0d45f
commit b4bd2b8aa7
2 changed files with 31 additions and 6 deletions

View File

@@ -11,20 +11,37 @@ import (
// BootHealthCheck verifies Boot watchdog health.
// "The vet checks on the dog."
type BootHealthCheck struct {
BaseCheck
FixableCheck
missingDir bool // track if directory is missing for Fix()
}
// NewBootHealthCheck creates a new Boot health check.
func NewBootHealthCheck() *BootHealthCheck {
return &BootHealthCheck{
BaseCheck: BaseCheck{
CheckName: "boot-health",
CheckDescription: "Check Boot watchdog health (the vet checks on the dog)",
CheckCategory: CategoryInfrastructure,
FixableCheck: FixableCheck{
BaseCheck: BaseCheck{
CheckName: "boot-health",
CheckDescription: "Check Boot watchdog health (the vet checks on the dog)",
CheckCategory: CategoryInfrastructure,
},
},
}
}
// CanFix returns true only if the directory is missing (we can create it).
func (c *BootHealthCheck) CanFix() bool {
return c.missingDir
}
// Fix creates the missing boot directory.
func (c *BootHealthCheck) Fix(ctx *CheckContext) error {
if !c.missingDir {
return nil
}
b := boot.New(ctx.TownRoot)
return b.EnsureDir()
}
// Run checks Boot health: directory, session, status, and marker freshness.
func (c *BootHealthCheck) Run(ctx *CheckContext) *CheckResult {
b := boot.New(ctx.TownRoot)
@@ -33,12 +50,13 @@ func (c *BootHealthCheck) Run(ctx *CheckContext) *CheckResult {
// Check 1: Boot directory exists
bootDir := b.Dir()
if _, err := os.Stat(bootDir); os.IsNotExist(err) {
c.missingDir = true
return &CheckResult{
Name: c.Name(),
Status: StatusWarning,
Message: "Boot directory not present",
Details: []string{fmt.Sprintf("Expected: %s", bootDir)},
FixHint: "Boot directory is created on first daemon run",
FixHint: "Run 'gt doctor --fix' to create it",
}
}