Files
2026-01-13 20:13:29 +08:00

48 lines
1.1 KiB
Go

package installcmd
import (
"os"
"github.com/spf13/cobra"
"yizhisec.com/hsv2/forge/internal/controller/installer"
)
func Check() *cobra.Command {
var (
workdir string
ignoreDisk bool
ignoreMemory bool
ignoreCPU bool
)
_cmd := &cobra.Command{
Use: "check",
Short: "Check system requirements",
Long: `Check system requirements for the project.`,
PreRun: func(cmd *cobra.Command, args []string) {
if os.Getenv("FORGE_NO_CHECK_DISK") == "true" {
ignoreDisk = true
}
if os.Getenv("FORGE_NO_CHECK_MEMORY") == "true" {
ignoreMemory = true
}
if os.Getenv("FORGE_NO_CHECK_CPU") == "true" {
ignoreCPU = true
}
},
RunE: func(cmd *cobra.Command, args []string) error {
_installer := installer.NewInstaller(workdir)
return _installer.HardwareCheck(
cmd.Context(),
installer.WithIgnoreDiskCheck(ignoreDisk),
installer.WithIgnoreMemoryCheck(ignoreMemory),
installer.WithIgnoreCPUCheck(ignoreCPU),
)
},
}
_cmd.Flags().StringVar(&workdir, "workdir", "/root/hs-installation", "Working directory")
return _cmd
}