Add: docker program existence check in config command

This commit is contained in:
2026-09-04 21:26:36 +05:00
parent 22d7f901d0
commit 350c78c40a
+20
View File
@@ -40,6 +40,10 @@ func CmdTestConfig(_ context.Context, _ *cli.Command) error {
checkNft := checkProgramNFT()
checkJournalctl := checkProgramJournalctl()
checkDocker := ""
if dockerSupport {
checkDocker = "\n " + checkProgramDocker()
}
fmt.Println(
"***\n"+i18n.Lang.T("cmd.daemon.config.test.settingTitle"),
@@ -53,6 +57,7 @@ func CmdTestConfig(_ context.Context, _ *cli.Command) error {
"\n"+i18n.Lang.T("cmd.daemon.config.test.checkingPrograms"),
"\n", checkNft,
"\n", checkJournalctl,
checkDocker,
"\n***",
)
return nil
@@ -156,6 +161,21 @@ func checkProgramJournalctl() string {
return resultOk(programTitle)
}
func checkProgramDocker() string {
programTitle := "docker"
path := setting.Config.BinaryLocations.Docker
if path == "" {
return resultError(programTitle, errors.New(i18n.Lang.T("cmd.daemon.config.test.pathEmpty", map[string]interface{}{"Program": programTitle})))
}
cmd := exec.Command(path, "--version")
if err := cmd.Run(); err != nil {
return resultError(programTitle, err)
}
return resultOk(programTitle)
}
func resultOk(title string) string {
return fmt.Sprintf("%s: \033[32mOk\033[0m", title)
}